Generated by Cython 3.0.9
Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.
Raw output: coreutils.c
+0001: # -*- coding: utf-8 -*-
__Pyx_TraceLine(1,0,__PYX_ERR(0, 1, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(100); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_format_to_datetime_line_145, __pyx_kp_u_Reformats_a_specified_column_in) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_adjust_to_samples_line_205, __pyx_kp_u_Adjusts_the_given_values_to_mat) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_unpack_list_of_dicts_line_286, __pyx_kp_u_Unpacks_a_list_of_dictionaries) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_get_params_line_323, __pyx_kp_u_Get_object_parameters_Object_ca) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_is_classification_task_line_379, __pyx_kp_u_Check_whether_the_given_arrays) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_to_numeric_dtypes_line_483, __pyx_kp_u_Converts_an_array_to_a_DataFram) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_listing_items_format_line_666, __pyx_kp_u_Format_list_by_enumerate_them_s) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_parse_attrs_line_736, __pyx_kp_u_Parse_attributes_using_the_regu) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_url_checker_line_771, __pyx_kp_u_check_whether_the_URL_is_reacha) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_shrunkformat_line_852, __pyx_kp_u_Format_class_and_add_ellipsis_w) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_is_installing_line_936, __pyx_kp_u_Install_or_uninstall_a_module_p) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_smart_strobj_recognition_line_10, __pyx_kp_u_Find_the_likelihood_word_in_the) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_repr_callable_obj_line_1127, __pyx_kp_u_Represent_callable_objects_Form) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_accept_types_line_1202, __pyx_kp_u_List_the_type_format_that_can_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_smart_format_line_1281, __pyx_kp_u_Smart_format_iterable_object_pa) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_format_notes_line_1379, __pyx_kp_u_Format_note_param_text_Text_to) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_remove_str_word_line_1486, __pyx_kp_u_Small_funnction_to_remove_a_wor) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_stn_check_split_type_line_1533, __pyx_kp_u_Read_data_line_and_check_for_da) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_display_infos_line_1593, __pyx_kp_u_Display_unique_element_on_list) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_fr_en_parser_line_1634, __pyx_kp_u_Parse_the_translated_data_file) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_convert_csvdata_from_fr_to_en_li, __pyx_kp_u_Translate_variable_data_from_fr) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_sanitize_unicode_string_line_176, __pyx_kp_u_Replace_all_spaces_and_remove_a) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_serialize_data_line_1963, __pyx_kp_u_Store_a_data_into_a_binary_file) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_load_serialized_data_line_2062, __pyx_kp_u_Load_data_from_dumped_file_para) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_fmt_text_line_2224, __pyx_kp_u_Function_format_text_from_anoma) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_reshape_line_2305, __pyx_kp_u_Detect_the_array_shape_and_resh) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_ismissing_line_2364, __pyx_kp_u_Get_the_missing_values_in_array) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_make_arr_consistent_line_2430, __pyx_kp_u_Make_arr_to_be_consistent_with) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_fit_ll_line_2540, __pyx_kp_u_Fit_EDI_by_location_and_reorgan) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_make_ids_line_2685, __pyx_kp_u_Generate_auto_Id_according_to_t) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_concat_array_from_list_line_2753, __pyx_kp_u_Concat_array_from_list_and_set) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_station_id_line_2803, __pyx_kp_u_From_id_get_the_station_name_as) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_strip_item_line_2900, __pyx_kp_u_Function_to_strip_item_around_s) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_parse_json_line_2954, __pyx_kp_u_Parse_Java_Script_Object_Notati) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_parse_csv_line_3070, __pyx_kp_u_Parse_comma_separated_file_or_c) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_is_iterable_line_3511, __pyx_kp_u_Asserts_iterable_object_and_ret) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_str2columns_line_3568, __pyx_kp_u_Split_text_from_the_non_alphanum) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_sanitize_frame_cols_line_3618, __pyx_kp_u_Remove_an_indesirable_character) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_to_hdf5_line_3709, __pyx_kp_u_Store_a_frame_data_in_hierachic) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_find_by_regex_line_3809, __pyx_kp_u_Find_pattern_in_object_whatever) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_is_in_if_line_3886, __pyx_kp_u_Raise_error_if_item_is_not_foun) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_map_specific_columns_line_3968, __pyx_kp_u_Apply_function_to_a_specific_co) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_smart_label_classifier_line_4169, __pyx_kp_u_map_smartly_the_numeric_array_i) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_smart_mapper_line_4349, __pyx_kp_u_Default_mapping_using_dict_to_v) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_zip_extractor_line_4391, __pyx_kp_u_Extract_ZIP_archive_objects_Can) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_validate_name_in_line_4487, __pyx_kp_u_Assert_name_in_multiples_given) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_get_confidence_ratio_line_4543, __pyx_kp_u_Get_ratio_of_confidence_in_arra) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_assert_ratio_line_4628, __pyx_kp_u_Assert_rate_value_between_a_spe) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_random_selector_line_4837, __pyx_kp_u_Randomly_select_the_number_of_va) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_get_xy_coordinates_line_5140, __pyx_kp_u_Check_whether_the_coordinate_val) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_pair_data_line_5275, __pyx_kp_u_Find_indentical_object_in_all_d) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_read_worksheets_line_5477, __pyx_kp_u_Read_sheets_and_returns_a_list) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_key_checker_line_5543, __pyx_kp_u_check_whether_a_give_key_exists) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_random_sampling_line_5640, __pyx_kp_u_Sampling_data_Parameters_d_arra) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_make_obj_consistent_if_line_5754, __pyx_kp_u_Combine_default_values_to_item_t) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_replace_data_line_5815, __pyx_kp_u_Duplicates_the_data_n_times_alo) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_convert_value_in_line_5921, __pyx_kp_u_Convert_value_based_on_the_refer) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_split_list_line_5976, __pyx_kp_u_Module_to_extract_a_slice_of_ele) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_key_search_line_6011, __pyx_kp_u_Find_key_in_a_list_of_default_ke) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_numstr2dms_line_6175, __pyx_kp_u_Convert_numerical_digit_string) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_store_or_write_hdf5_line_6274, __pyx_kp_u_Store_data_to_hdf5_or_write_dat) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_ellipsis2false_line_6475, __pyx_kp_u_Turn_all_parameter_arguments_to) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_type_of_target_line_6501, __pyx_kp_u_Determine_the_type_of_data_indi) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_add_noises_to_line_6551, __pyx_kp_u_Adds_NaN_or_specified_missing_v) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_parse_gaussian_noise_line_6679, __pyx_kp_u_Parses_the_noise_parameter_to_d) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_nan_to_na_line_6751, __pyx_kp_u_Converts_specified_NaN_values_i) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_validate_noise_line_6846, __pyx_kp_u_Validates_the_noise_parameter_a) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_fancier_repr_formatter_line_6896, __pyx_kp_u_Generates_a_formatted_string_re) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_generic_getattr_line_6939, __pyx_kp_u_A_generic_attribute_accessor_fo) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_validate_url_line_7012, __pyx_kp_u_Check_if_the_provided_string_is) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_validate_url_by_validators_line, __pyx_kp_u_Check_if_the_provided_string_is_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_is_module_installed_line_7078, __pyx_kp_u_Check_if_a_Python_module_is_ins) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_normalize_string_line_7244, __pyx_kp_u_Normalizes_a_string_by_applying) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_format_and_print_dict_line_7359, __pyx_kp_u_Formats_and_prints_the_contents) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_fill_nan_in_line_7420, __pyx_kp_u_Fills_NaN_values_in_a_Pandas_Da) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_get_valid_kwargs_line_7475, __pyx_kp_u_Filters_keyword_arguments_kwarg) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_extract_coordinates_line_7770, __pyx_kp_u_Extracts_x_and_y_coordinate_arr) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_validate_feature_line_7921, __pyx_kp_u_Validate_the_existence_of_speci) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_features_in_line_7964, __pyx_kp_u_Control_whether_the_specified_f) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_find_features_in_line_8006, __pyx_kp_u_Retrieve_the_categorical_or_num) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_split_train_test_line_8077, __pyx_kp_u_Split_a_DataFrame_into_train_an) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_test_set_check_id_line_8115, __pyx_kp_u_Check_if_an_instance_should_be) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_split_train_test_by_id_line_8157, __pyx_kp_u_Split_a_DataFrame_into_train_an_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_parallelize_jobs_line_8229, __pyx_kp_u_Parallelize_the_execution_of_a) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_denormalize_line_8305, __pyx_kp_u_Denormalizes_data_from_a_normal) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_squeeze_specific_dim_line_8383, __pyx_kp_u_Squeeze_specific_dimensions_of) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_contains_delimiter_line_8449, __pyx_kp_u_Checks_if_the_given_string_cont) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_convert_to_structured_format_lin, __pyx_kp_u_Converts_input_objects_to_struc) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_resample_data_line_8600, __pyx_kp_u_Resample_multiple_data_structur) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_get_valid_key_line_8699, __pyx_kp_u_Validates_an_input_key_and_subs) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_process_and_extract_data_line_87, __pyx_kp_u_Extracts_and_processes_data_fro) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_to_series_if_line_8916, __pyx_kp_u_Constructs_a_pandas_Series_from) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_ensure_visualization_compatibili_2, __pyx_kp_u_Evaluates_and_prepares_the_resu) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_generate_mpl_styles_line_9055, __pyx_kp_u_Generates_a_list_of_matplotlib) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_generate_alpha_values_line_9125, __pyx_kp_u_Generates_a_list_of_alpha_trans) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_decompose_colormap_line_9172, __pyx_kp_u_Decomposes_a_colormap_into_a_li) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_get_colors_and_alphas_line_9198, __pyx_kp_u_Generates_a_sequence_of_color_c) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_colors_to_names_line_9332, __pyx_kp_u_Converts_a_sequence_of_RGB_or_R) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_closest_color_line_9395, __pyx_kp_u_Finds_the_closest_named_CSS4_co) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_kp_u_check_uniform_type_line_9472, __pyx_kp_u_Checks_whether_elements_in_valu) < 0) __PYX_ERR(0, 1, __pyx_L1_error) if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_2, __pyx_t_8) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
0002: # License: BSD-3-Clause
0003: # Author: LKouadio <etanoyau@gmail.com>
0004: """
0005: `coreutils` module provides a diverse set of utility functions and tools for
0006: data manipulation, validation, formatting, and processing.
0007: """
0008:
0009: from __future__ import print_function
+0010: import os
__Pyx_TraceLine(10,0,__PYX_ERR(0, 10, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_os, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_2) < 0) __PYX_ERR(0, 10, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0011: import re
__Pyx_TraceLine(11,0,__PYX_ERR(0, 11, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_re, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0012: import sys
__Pyx_TraceLine(12,0,__PYX_ERR(0, 12, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0013: import csv
__Pyx_TraceLine(13,0,__PYX_ERR(0, 13, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_csv, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_csv, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0014: import copy
__Pyx_TraceLine(14,0,__PYX_ERR(0, 14, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_copy, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_copy, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0015: import json
__Pyx_TraceLine(15,0,__PYX_ERR(0, 15, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_json_2, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_json_2, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0016: import h5py
__Pyx_TraceLine(16,0,__PYX_ERR(0, 16, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_h5py, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_h5py, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0017: import yaml
__Pyx_TraceLine(17,0,__PYX_ERR(0, 17, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_yaml, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_yaml, __pyx_t_2) < 0) __PYX_ERR(0, 17, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0018: import scipy
__Pyx_TraceLine(18,0,__PYX_ERR(0, 18, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_scipy, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_scipy, __pyx_t_2) < 0) __PYX_ERR(0, 18, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0019: import joblib
__Pyx_TraceLine(19,0,__PYX_ERR(0, 19, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_joblib, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_joblib, __pyx_t_2) < 0) __PYX_ERR(0, 19, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0020: import pickle
__Pyx_TraceLine(20,0,__PYX_ERR(0, 20, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_pickle, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pickle, __pyx_t_2) < 0) __PYX_ERR(0, 20, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0021: import shutil
__Pyx_TraceLine(21,0,__PYX_ERR(0, 21, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_shutil, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_shutil, __pyx_t_2) < 0) __PYX_ERR(0, 21, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0022: import numbers
__Pyx_TraceLine(22,0,__PYX_ERR(0, 22, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_numbers, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_numbers, __pyx_t_2) < 0) __PYX_ERR(0, 22, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0023: import random
__Pyx_TraceLine(23,0,__PYX_ERR(0, 23, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_random, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_random, __pyx_t_2) < 0) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0024: import inspect
__Pyx_TraceLine(24,0,__PYX_ERR(0, 24, __pyx_L1_error)) __pyx_t_2 = __Pyx_patch_inspect(__Pyx_ImportDottedModule(__pyx_n_s_inspect, NULL)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_inspect, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0025: import hashlib
__Pyx_TraceLine(25,0,__PYX_ERR(0, 25, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_hashlib, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_hashlib, __pyx_t_2) < 0) __PYX_ERR(0, 25, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0026: import datetime
__Pyx_TraceLine(26,0,__PYX_ERR(0, 26, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_datetime, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_datetime, __pyx_t_2) < 0) __PYX_ERR(0, 26, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0027: import warnings
__Pyx_TraceLine(27,0,__PYX_ERR(0, 27, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_warnings, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_warnings, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0028: import itertools
__Pyx_TraceLine(28,0,__PYX_ERR(0, 28, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_itertools, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_itertools, __pyx_t_2) < 0) __PYX_ERR(0, 28, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0029: import subprocess
__Pyx_TraceLine(29,0,__PYX_ERR(0, 29, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_subprocess, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_subprocess, __pyx_t_2) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0030: import multiprocessing
__Pyx_TraceLine(30,0,__PYX_ERR(0, 30, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_multiprocessing, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_multiprocessing, __pyx_t_2) < 0) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0031: from zipfile import ZipFile
__Pyx_TraceLine(31,0,__PYX_ERR(0, 31, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_ZipFile); __Pyx_GIVEREF(__pyx_n_s_ZipFile); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ZipFile)) __PYX_ERR(0, 31, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_zipfile, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ZipFile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ZipFile, __pyx_t_2) < 0) __PYX_ERR(0, 31, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0032: from six.moves import urllib
__Pyx_TraceLine(32,0,__PYX_ERR(0, 32, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_urllib); __Pyx_GIVEREF(__pyx_n_s_urllib); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_urllib)) __PYX_ERR(0, 32, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_six_moves, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_urllib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_urllib, __pyx_t_3) < 0) __PYX_ERR(0, 32, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0033: from collections import defaultdict
__Pyx_TraceLine(33,0,__PYX_ERR(0, 33, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_defaultdict); __Pyx_GIVEREF(__pyx_n_s_defaultdict); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_defaultdict)) __PYX_ERR(0, 33, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_collections, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_defaultdict, __pyx_t_2) < 0) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0034: from collections.abc import Sequence
__Pyx_TraceLine(34,0,__PYX_ERR(0, 34, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_Sequence); __Pyx_GIVEREF(__pyx_n_s_Sequence); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Sequence)) __PYX_ERR(0, 34, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_collections_abc, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Sequence, __pyx_t_3) < 0) __PYX_ERR(0, 34, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0035: from concurrent.futures import as_completed
__Pyx_TraceLine(35,0,__PYX_ERR(0, 35, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_as_completed); __Pyx_GIVEREF(__pyx_n_s_as_completed); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_as_completed)) __PYX_ERR(0, 35, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_concurrent_futures, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_as_completed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_as_completed, __pyx_t_2) < 0) __PYX_ERR(0, 35, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0036: from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
__Pyx_TraceLine(36,0,__PYX_ERR(0, 36, __pyx_L1_error)) __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_ThreadPoolExecutor); __Pyx_GIVEREF(__pyx_n_s_ThreadPoolExecutor); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_ThreadPoolExecutor)) __PYX_ERR(0, 36, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_ProcessPoolExecutor); __Pyx_GIVEREF(__pyx_n_s_ProcessPoolExecutor); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_ProcessPoolExecutor)) __PYX_ERR(0, 36, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_concurrent_futures, __pyx_t_3, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ThreadPoolExecutor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ThreadPoolExecutor, __pyx_t_3) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ProcessPoolExecutor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ProcessPoolExecutor, __pyx_t_3) < 0) __PYX_ERR(0, 36, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0037:
+0038: import numpy as np
__Pyx_TraceLine(38,0,__PYX_ERR(0, 38, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_numpy, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 38, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0039: import pandas as pd
__Pyx_TraceLine(39,0,__PYX_ERR(0, 39, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_pandas, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pd, __pyx_t_2) < 0) __PYX_ERR(0, 39, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0040: import matplotlib.pyplot as plt
__Pyx_TraceLine(40,0,__PYX_ERR(0, 40, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_matplotlib_pyplot, __pyx_tuple__77); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_plt, __pyx_t_2) < 0) __PYX_ERR(0, 40, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0041: import matplotlib.colors as mcolors
__Pyx_TraceLine(41,0,__PYX_ERR(0, 41, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_matplotlib_colors, __pyx_tuple__350); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_mcolors, __pyx_t_2) < 0) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__350 = PyTuple_Pack(2, __pyx_n_s_matplotlib, __pyx_n_s_colors); if (unlikely(!__pyx_tuple__350)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__350); __Pyx_GIVEREF(__pyx_tuple__350);
0042:
+0043: from .._gofastlog import gofastlog
__Pyx_TraceLine(43,0,__PYX_ERR(0, 43, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_gofastlog_2); __Pyx_GIVEREF(__pyx_n_s_gofastlog_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_gofastlog_2)) __PYX_ERR(0, 43, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_gofastlog, __pyx_t_2, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_gofastlog_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_gofastlog_2, __pyx_t_2) < 0) __PYX_ERR(0, 43, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0044: from ..api.types import Union, Series,Tuple,Dict,Optional,Iterable, Any, Set
__Pyx_TraceLine(44,0,__PYX_ERR(0, 44, __pyx_L1_error)) __pyx_t_3 = PyList_New(8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_Union); __Pyx_GIVEREF(__pyx_n_s_Union); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Union)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Series); __Pyx_GIVEREF(__pyx_n_s_Series); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_Series)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Tuple); __Pyx_GIVEREF(__pyx_n_s_Tuple); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_s_Tuple)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Dict); __Pyx_GIVEREF(__pyx_n_s_Dict); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_s_Dict)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Optional); __Pyx_GIVEREF(__pyx_n_s_Optional); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 4, __pyx_n_s_Optional)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Iterable); __Pyx_GIVEREF(__pyx_n_s_Iterable); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 5, __pyx_n_s_Iterable)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Any); __Pyx_GIVEREF(__pyx_n_s_Any); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 6, __pyx_n_s_Any)) __PYX_ERR(0, 44, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Set); __Pyx_GIVEREF(__pyx_n_s_Set); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 7, __pyx_n_s_Set)) __PYX_ERR(0, 44, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_api_types, __pyx_t_3, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Union); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Union, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Series); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Series, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Tuple, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Dict, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Optional); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Optional, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Iterable, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Any, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Set); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Set, __pyx_t_3) < 0) __PYX_ERR(0, 44, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0045: from ..api.types import _T,_Sub, _F, ArrayLike,List, DataFrame, NDArray, Text
__Pyx_TraceLine(45,0,__PYX_ERR(0, 45, __pyx_L1_error)) __pyx_t_2 = PyList_New(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_T_2); __Pyx_GIVEREF(__pyx_n_s_T_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_T_2)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Sub); __Pyx_GIVEREF(__pyx_n_s_Sub); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_Sub)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_F); __Pyx_GIVEREF(__pyx_n_s_F); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_F)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_ArrayLike); __Pyx_GIVEREF(__pyx_n_s_ArrayLike); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_ArrayLike)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_List); __Pyx_GIVEREF(__pyx_n_s_List); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_List)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_DataFrame); __Pyx_GIVEREF(__pyx_n_s_DataFrame); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_DataFrame)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_NDArray); __Pyx_GIVEREF(__pyx_n_s_NDArray); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_NDArray)) __PYX_ERR(0, 45, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Text); __Pyx_GIVEREF(__pyx_n_s_Text); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_Text)) __PYX_ERR(0, 45, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_api_types, __pyx_t_2, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_T_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_T_2, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Sub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Sub, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_F); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_F, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ArrayLike); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ArrayLike, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_List); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_List, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_DataFrame, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_NDArray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_NDArray, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_Text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Text, __pyx_t_2) < 0) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0046: from ._dependency import import_optional_dependency
__Pyx_TraceLine(46,0,__PYX_ERR(0, 46, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_import_optional_dependency); __Pyx_GIVEREF(__pyx_n_s_import_optional_dependency); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_import_optional_dependency)) __PYX_ERR(0, 46, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_dependency, __pyx_t_3, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_import_optional_dependency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_import_optional_dependency, __pyx_t_3) < 0) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0047: from ..compat.scipy import ensure_scipy_compatibility
__Pyx_TraceLine(47,0,__PYX_ERR(0, 47, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_ensure_scipy_compatibility); __Pyx_GIVEREF(__pyx_n_s_ensure_scipy_compatibility); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_ensure_scipy_compatibility)) __PYX_ERR(0, 47, __pyx_L1_error); __pyx_t_3 = __Pyx_Import(__pyx_n_s_compat_scipy, __pyx_t_2, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_ensure_scipy_compatibility); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_scipy_compatibility, __pyx_t_2) < 0) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0048: from ..compat.scipy import check_scipy_interpolate, optimize_minimize
__Pyx_TraceLine(48,0,__PYX_ERR(0, 48, __pyx_L1_error)) __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_s_check_scipy_interpolate); __Pyx_GIVEREF(__pyx_n_s_check_scipy_interpolate); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_check_scipy_interpolate)) __PYX_ERR(0, 48, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_optimize_minimize); __Pyx_GIVEREF(__pyx_n_s_optimize_minimize); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_n_s_optimize_minimize)) __PYX_ERR(0, 48, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_compat_scipy, __pyx_t_3, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_check_scipy_interpolate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_scipy_interpolate, __pyx_t_3) < 0) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_optimize_minimize); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_d, __pyx_n_s_optimize_minimize, __pyx_t_3) < 0) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0049:
+0050: _logger = gofastlog.get_gofast_logger(__name__)
__Pyx_TraceLine(50,0,__PYX_ERR(0, 50, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_gofastlog_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_get_gofast_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_logger, __pyx_t_4) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0051:
+0052: __all__=[
__Pyx_TraceLine(52,0,__PYX_ERR(0, 52, __pyx_L1_error)) __pyx_t_4 = PyList_New(89); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_u_add_noises_to); __Pyx_GIVEREF(__pyx_n_u_add_noises_to); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_add_noises_to)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_adjust_to_samples); __Pyx_GIVEREF(__pyx_n_u_adjust_to_samples); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_adjust_to_samples)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_assert_ratio); __Pyx_GIVEREF(__pyx_n_u_assert_ratio); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 2, __pyx_n_u_assert_ratio)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_check_dimensionality); __Pyx_GIVEREF(__pyx_n_u_check_dimensionality); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 3, __pyx_n_u_check_dimensionality)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_check_uniform_type); __Pyx_GIVEREF(__pyx_n_u_check_uniform_type); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 4, __pyx_n_u_check_uniform_type)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_cleaner); __Pyx_GIVEREF(__pyx_n_u_cleaner); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 5, __pyx_n_u_cleaner)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_colors_to_names); __Pyx_GIVEREF(__pyx_n_u_colors_to_names); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 6, __pyx_n_u_colors_to_names)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_cpath); __Pyx_GIVEREF(__pyx_n_u_cpath); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 7, __pyx_n_u_cpath)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_decompose_colormap); __Pyx_GIVEREF(__pyx_n_u_decompose_colormap); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 8, __pyx_n_u_decompose_colormap)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_denormalize); __Pyx_GIVEREF(__pyx_n_u_denormalize); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 9, __pyx_n_u_denormalize)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_display_infos); __Pyx_GIVEREF(__pyx_n_u_display_infos); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 10, __pyx_n_u_display_infos)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_download_progress_hook); __Pyx_GIVEREF(__pyx_n_u_download_progress_hook); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 11, __pyx_n_u_download_progress_hook)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_exist_features); __Pyx_GIVEREF(__pyx_n_u_exist_features); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 12, __pyx_n_u_exist_features)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_extract_coordinates); __Pyx_GIVEREF(__pyx_n_u_extract_coordinates); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 13, __pyx_n_u_extract_coordinates)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_features_in); __Pyx_GIVEREF(__pyx_n_u_features_in); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 14, __pyx_n_u_features_in)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_fetch_json_data_from_url); __Pyx_GIVEREF(__pyx_n_u_fetch_json_data_from_url); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 15, __pyx_n_u_fetch_json_data_from_url)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_fill_nan_in); __Pyx_GIVEREF(__pyx_n_u_fill_nan_in); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 16, __pyx_n_u_fill_nan_in)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_find_by_regex); __Pyx_GIVEREF(__pyx_n_u_find_by_regex); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 17, __pyx_n_u_find_by_regex)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_find_close_position); __Pyx_GIVEREF(__pyx_n_u_find_close_position); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 18, __pyx_n_u_find_close_position)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_find_features_in); __Pyx_GIVEREF(__pyx_n_u_find_features_in); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 19, __pyx_n_u_find_features_in)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_format_to_datetime); __Pyx_GIVEREF(__pyx_n_u_format_to_datetime); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 20, __pyx_n_u_format_to_datetime)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_generate_alpha_values); __Pyx_GIVEREF(__pyx_n_u_generate_alpha_values); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 21, __pyx_n_u_generate_alpha_values)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_generate_mpl_styles); __Pyx_GIVEREF(__pyx_n_u_generate_mpl_styles); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 22, __pyx_n_u_generate_mpl_styles)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_generic_getattr); __Pyx_GIVEREF(__pyx_n_u_generic_getattr); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 23, __pyx_n_u_generic_getattr)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_colors_and_alphas); __Pyx_GIVEREF(__pyx_n_u_get_colors_and_alphas); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 24, __pyx_n_u_get_colors_and_alphas)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_confidence_ratio); __Pyx_GIVEREF(__pyx_n_u_get_confidence_ratio); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 25, __pyx_n_u_get_confidence_ratio)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_installation_name); __Pyx_GIVEREF(__pyx_n_u_get_installation_name); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 26, __pyx_n_u_get_installation_name)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_params); __Pyx_GIVEREF(__pyx_n_u_get_params); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 27, __pyx_n_u_get_params)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_valid_key); __Pyx_GIVEREF(__pyx_n_u_get_valid_key); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 28, __pyx_n_u_get_valid_key)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_valid_kwargs); __Pyx_GIVEREF(__pyx_n_u_get_valid_kwargs); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 29, __pyx_n_u_get_valid_kwargs)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_get_xy_coordinates); __Pyx_GIVEREF(__pyx_n_u_get_xy_coordinates); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 30, __pyx_n_u_get_xy_coordinates)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_hex_to_rgb); __Pyx_GIVEREF(__pyx_n_u_hex_to_rgb); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 31, __pyx_n_u_hex_to_rgb)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_interpol_scipy); __Pyx_GIVEREF(__pyx_n_u_interpol_scipy); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 32, __pyx_n_u_interpol_scipy)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_classification_task); __Pyx_GIVEREF(__pyx_n_u_is_classification_task); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 33, __pyx_n_u_is_classification_task)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_depth_in); __Pyx_GIVEREF(__pyx_n_u_is_depth_in); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 34, __pyx_n_u_is_depth_in)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_in_if); __Pyx_GIVEREF(__pyx_n_u_is_in_if); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 35, __pyx_n_u_is_in_if)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_installing); __Pyx_GIVEREF(__pyx_n_u_is_installing); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 36, __pyx_n_u_is_installing)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_iterable); __Pyx_GIVEREF(__pyx_n_u_is_iterable); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 37, __pyx_n_u_is_iterable)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_module_installed); __Pyx_GIVEREF(__pyx_n_u_is_module_installed); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 38, __pyx_n_u_is_module_installed)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_ismissing); __Pyx_GIVEREF(__pyx_n_u_ismissing); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 39, __pyx_n_u_ismissing)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_load_serialized_data); __Pyx_GIVEREF(__pyx_n_u_load_serialized_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 40, __pyx_n_u_load_serialized_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_make_ids); __Pyx_GIVEREF(__pyx_n_u_make_ids); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 41, __pyx_n_u_make_ids)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_move_cfile); __Pyx_GIVEREF(__pyx_n_u_move_cfile); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 42, __pyx_n_u_move_cfile)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_nan_to_na); __Pyx_GIVEREF(__pyx_n_u_nan_to_na); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 43, __pyx_n_u_nan_to_na)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_normalize_string); __Pyx_GIVEREF(__pyx_n_u_normalize_string); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 44, __pyx_n_u_normalize_string)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_numstr2dms); __Pyx_GIVEREF(__pyx_n_u_numstr2dms); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 45, __pyx_n_u_numstr2dms)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_pair_data); __Pyx_GIVEREF(__pyx_n_u_pair_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 46, __pyx_n_u_pair_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_parallelize_jobs); __Pyx_GIVEREF(__pyx_n_u_parallelize_jobs); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 47, __pyx_n_u_parallelize_jobs)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_parse_attrs); __Pyx_GIVEREF(__pyx_n_u_parse_attrs); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 48, __pyx_n_u_parse_attrs)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_parse_csv); __Pyx_GIVEREF(__pyx_n_u_parse_csv); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 49, __pyx_n_u_parse_csv)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_parse_json); __Pyx_GIVEREF(__pyx_n_u_parse_json); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 50, __pyx_n_u_parse_json)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_parse_md_data); __Pyx_GIVEREF(__pyx_n_u_parse_md_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 51, __pyx_n_u_parse_md_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_parse_yaml); __Pyx_GIVEREF(__pyx_n_u_parse_yaml); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 52, __pyx_n_u_parse_yaml)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_process_and_extract_data); __Pyx_GIVEREF(__pyx_n_u_process_and_extract_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 53, __pyx_n_u_process_and_extract_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_projection_validator); __Pyx_GIVEREF(__pyx_n_u_projection_validator); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 54, __pyx_n_u_projection_validator)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_random_sampling); __Pyx_GIVEREF(__pyx_n_u_random_sampling); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 55, __pyx_n_u_random_sampling)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_random_selector); __Pyx_GIVEREF(__pyx_n_u_random_selector); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 56, __pyx_n_u_random_selector)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_random_state_validator); __Pyx_GIVEREF(__pyx_n_u_random_state_validator); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 57, __pyx_n_u_random_state_validator)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_read_from_excelsheets); __Pyx_GIVEREF(__pyx_n_u_read_from_excelsheets); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 58, __pyx_n_u_read_from_excelsheets)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_read_main); __Pyx_GIVEREF(__pyx_n_u_read_main); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 59, __pyx_n_u_read_main)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_read_worksheets); __Pyx_GIVEREF(__pyx_n_u_read_worksheets); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 60, __pyx_n_u_read_worksheets)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_rename_files); __Pyx_GIVEREF(__pyx_n_u_rename_files); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 61, __pyx_n_u_rename_files)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_replace_data); __Pyx_GIVEREF(__pyx_n_u_replace_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 62, __pyx_n_u_replace_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_resample_data); __Pyx_GIVEREF(__pyx_n_u_resample_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 63, __pyx_n_u_resample_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_reshape); __Pyx_GIVEREF(__pyx_n_u_reshape); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 64, __pyx_n_u_reshape)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_sanitize_frame_cols); __Pyx_GIVEREF(__pyx_n_u_sanitize_frame_cols); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 65, __pyx_n_u_sanitize_frame_cols)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_sanitize_unicode_string); __Pyx_GIVEREF(__pyx_n_u_sanitize_unicode_string); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 66, __pyx_n_u_sanitize_unicode_string)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_save_job); __Pyx_GIVEREF(__pyx_n_u_save_job); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 67, __pyx_n_u_save_job)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_savepath_2); __Pyx_GIVEREF(__pyx_n_u_savepath_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 68, __pyx_n_u_savepath_2)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_serialize_data); __Pyx_GIVEREF(__pyx_n_u_serialize_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 69, __pyx_n_u_serialize_data)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_smart_label_classifier); __Pyx_GIVEREF(__pyx_n_u_smart_label_classifier); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 70, __pyx_n_u_smart_label_classifier)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_split_train_test); __Pyx_GIVEREF(__pyx_n_u_split_train_test); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 71, __pyx_n_u_split_train_test)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_split_train_test_by_id); __Pyx_GIVEREF(__pyx_n_u_split_train_test_by_id); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 72, __pyx_n_u_split_train_test_by_id)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_squeeze_specific_dim); __Pyx_GIVEREF(__pyx_n_u_squeeze_specific_dim); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 73, __pyx_n_u_squeeze_specific_dim)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_store_or_write_hdf5); __Pyx_GIVEREF(__pyx_n_u_store_or_write_hdf5); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 74, __pyx_n_u_store_or_write_hdf5)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_str2columns); __Pyx_GIVEREF(__pyx_n_u_str2columns); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 75, __pyx_n_u_str2columns)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_test_set_check_id); __Pyx_GIVEREF(__pyx_n_u_test_set_check_id); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 76, __pyx_n_u_test_set_check_id)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_to_hdf5); __Pyx_GIVEREF(__pyx_n_u_to_hdf5); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 77, __pyx_n_u_to_hdf5)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_to_numeric_dtypes); __Pyx_GIVEREF(__pyx_n_u_to_numeric_dtypes); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 78, __pyx_n_u_to_numeric_dtypes)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_to_series_if); __Pyx_GIVEREF(__pyx_n_u_to_series_if); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 79, __pyx_n_u_to_series_if)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_type_of_target); __Pyx_GIVEREF(__pyx_n_u_type_of_target); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 80, __pyx_n_u_type_of_target)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_unpack_list_of_dicts); __Pyx_GIVEREF(__pyx_n_u_unpack_list_of_dicts); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 81, __pyx_n_u_unpack_list_of_dicts)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_url_checker); __Pyx_GIVEREF(__pyx_n_u_url_checker); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 82, __pyx_n_u_url_checker)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_validate_feature); __Pyx_GIVEREF(__pyx_n_u_validate_feature); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 83, __pyx_n_u_validate_feature)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_validate_ratio); __Pyx_GIVEREF(__pyx_n_u_validate_ratio); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 84, __pyx_n_u_validate_ratio)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_validate_url); __Pyx_GIVEREF(__pyx_n_u_validate_url); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 85, __pyx_n_u_validate_url)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_validate_url_by_validators); __Pyx_GIVEREF(__pyx_n_u_validate_url_by_validators); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 86, __pyx_n_u_validate_url_by_validators)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_wrap_infos); __Pyx_GIVEREF(__pyx_n_u_wrap_infos); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 87, __pyx_n_u_wrap_infos)) __PYX_ERR(0, 52, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_zip_extractor); __Pyx_GIVEREF(__pyx_n_u_zip_extractor); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 88, __pyx_n_u_zip_extractor)) __PYX_ERR(0, 52, __pyx_L1_error); if (PyDict_SetItem(__pyx_d, __pyx_n_s_all_2, __pyx_t_4) < 0) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0053: 'add_noises_to',
0054: 'adjust_to_samples',
0055: 'assert_ratio',
0056: 'check_dimensionality',
0057: 'check_uniform_type',
0058: 'cleaner',
0059: 'colors_to_names',
0060: 'cpath',
0061: 'decompose_colormap',
0062: 'denormalize',
0063: 'display_infos',
0064: 'download_progress_hook',
0065: 'exist_features',
0066: 'extract_coordinates',
0067: 'features_in',
0068: 'fetch_json_data_from_url',
0069: 'fill_nan_in',
0070: 'find_by_regex',
0071: 'find_close_position',
0072: 'find_features_in',
0073: 'format_to_datetime',
0074: 'generate_alpha_values',
0075: 'generate_mpl_styles',
0076: 'generic_getattr',
0077: 'get_colors_and_alphas',
0078: 'get_confidence_ratio',
0079: 'get_installation_name',
0080: 'get_params',
0081: 'get_valid_key',
0082: 'get_valid_kwargs',
0083: 'get_xy_coordinates',
0084: 'hex_to_rgb',
0085: 'interpol_scipy',
0086: 'is_classification_task',
0087: 'is_depth_in',
0088: 'is_in_if',
0089: 'is_installing',
0090: 'is_iterable',
0091: 'is_module_installed',
0092: 'ismissing',
0093: 'load_serialized_data',
0094: 'make_ids',
0095: 'move_cfile',
0096: 'nan_to_na',
0097: 'normalize_string',
0098: 'numstr2dms',
0099: 'pair_data',
0100: 'parallelize_jobs',
0101: 'parse_attrs',
0102: 'parse_csv',
0103: 'parse_json',
0104: 'parse_md_data',
0105: 'parse_yaml',
0106: 'process_and_extract_data',
0107: 'projection_validator',
0108: 'random_sampling',
0109: 'random_selector',
0110: 'random_state_validator',
0111: 'read_from_excelsheets',
0112: 'read_main',
0113: 'read_worksheets',
0114: 'rename_files',
0115: # 'repeat_item_insertion',
0116: 'replace_data',
0117: 'resample_data',
0118: 'reshape',
0119: 'sanitize_frame_cols',
0120: 'sanitize_unicode_string',
0121: 'save_job',
0122: 'savepath_',
0123: 'serialize_data',
0124: 'smart_label_classifier',
0125: 'split_train_test',
0126: 'split_train_test_by_id',
0127: 'squeeze_specific_dim',
0128: 'store_or_write_hdf5',
0129: 'str2columns',
0130: 'test_set_check_id',
0131: 'to_hdf5',
0132: 'to_numeric_dtypes',
0133: 'to_series_if',
0134: 'type_of_target',
0135: 'unpack_list_of_dicts',
0136: 'url_checker',
0137: 'validate_feature',
0138: 'validate_ratio',
0139: 'validate_url',
0140: 'validate_url_by_validators',
0141: 'wrap_infos',
0142: 'zip_extractor'
0143: ]
0144:
+0145: def format_to_datetime(data, date_col, verbose=0, **dt_kws):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_1format_to_datetime(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_format_to_datetime, "\n Reformats a specified column in a DataFrame to Pandas datetime format.\n\n This function attempts to convert the values in the specified column of a \n DataFrame to Pandas datetime objects. If the conversion is successful, \n the DataFrame with the updated column is returned. If the conversion fails, \n a message describing the error is printed, and the original \n DataFrame is returned.\n\n Parameters\n ----------\n data : pandas.DataFrame\n The DataFrame containing the column to be reformatted.\n date_col : str\n The name of the column to be converted to datetime format.\n verbose : int, optional\n Verbosity mode; 0 or 1. If 1, prints messages about the conversion \n process.Default is 0 (silent mode).\n **dt_kws : dict, optional\n Additional keyword arguments to pass to `pd.to_datetime` function.\n\n Returns\n -------\n pandas.DataFrame\n A DataFrame with the specified column in datetime format. If conversion\n fails, the original DataFrame is returned.\n\n Raises\n ------\n ValueError\n If the specified column is not found in the DataFrame.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import format_to_datetime\n >>> df = pd.DataFrame({\n ... 'Date': ['2021-01-01', '01/02/2021', '03-Jan-2021', '2021.04.01',\n '05 May 2021'],\n ... 'Value': [1, 2, 3, 4, 5]\n ... })\n >>> df = format_to_datetime(df, 'Date')\n >>> print(df.dtypes)\n Date datetime64[ns]\n Value int64\n dtype: object\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_1format_to_datetime = {"format_to_datetime", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_1format_to_datetime, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_format_to_datetime}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_1format_to_datetime(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_date_col = 0; PyObject *__pyx_v_verbose = 0; PyObject *__pyx_v_dt_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("format_to_datetime (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_dt_kws = PyDict_New(); if (unlikely(!__pyx_v_dt_kws)) return NULL; __Pyx_GOTREF(__pyx_v_dt_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_date_col,&__pyx_n_s_verbose,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_date_col)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("format_to_datetime", 0, 2, 3, 1); __PYX_ERR(0, 145, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_dt_kws, values + 0, kwd_pos_args, "format_to_datetime") < 0)) __PYX_ERR(0, 145, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_date_col = values[1]; __pyx_v_verbose = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("format_to_datetime", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 145, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_dt_kws); __pyx_v_dt_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.format_to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_format_to_datetime(__pyx_self, __pyx_v_data, __pyx_v_date_col, __pyx_v_verbose, __pyx_v_dt_kws); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_DECREF(__pyx_v_dt_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_format_to_datetime(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_date_col, PyObject *__pyx_v_verbose, PyObject *__pyx_v_dt_kws) { PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj_) __Pyx_TraceCall("format_to_datetime", __pyx_f[0], 145, 0, __PYX_ERR(0, 145, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.format_to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__351 = PyTuple_Pack(5, __pyx_n_s_data, __pyx_n_s_date_col, __pyx_n_s_verbose, __pyx_n_s_dt_kws, __pyx_n_s_e); if (unlikely(!__pyx_tuple__351)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__351); __Pyx_GIVEREF(__pyx_tuple__351); __pyx_codeobj_ = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__351, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_format_to_datetime, 145, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj_)) __PYX_ERR(0, 145, __pyx_L1_error) /* … */ __Pyx_TraceLine(145,0,__PYX_ERR(0, 145, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_1format_to_datetime, 0, __pyx_n_s_format_to_datetime, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj_)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__352); if (PyDict_SetItem(__pyx_d, __pyx_n_s_format_to_datetime, __pyx_t_4) < 0) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__352 = PyTuple_Pack(1, ((PyObject *)__pyx_int_0)); if (unlikely(!__pyx_tuple__352)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__352); __Pyx_GIVEREF(__pyx_tuple__352);
0146: """
0147: Reformats a specified column in a DataFrame to Pandas datetime format.
0148:
0149: This function attempts to convert the values in the specified column of a
0150: DataFrame to Pandas datetime objects. If the conversion is successful,
0151: the DataFrame with the updated column is returned. If the conversion fails,
0152: a message describing the error is printed, and the original
0153: DataFrame is returned.
0154:
0155: Parameters
0156: ----------
0157: data : pandas.DataFrame
0158: The DataFrame containing the column to be reformatted.
0159: date_col : str
0160: The name of the column to be converted to datetime format.
0161: verbose : int, optional
0162: Verbosity mode; 0 or 1. If 1, prints messages about the conversion
0163: process.Default is 0 (silent mode).
0164: **dt_kws : dict, optional
0165: Additional keyword arguments to pass to `pd.to_datetime` function.
0166:
0167: Returns
0168: -------
0169: pandas.DataFrame
0170: A DataFrame with the specified column in datetime format. If conversion
0171: fails, the original DataFrame is returned.
0172:
0173: Raises
0174: ------
0175: ValueError
0176: If the specified column is not found in the DataFrame.
0177:
0178: Examples
0179: --------
0180: >>> from gofast.tools.coreutils import format_to_datetime
0181: >>> df = pd.DataFrame({
0182: ... 'Date': ['2021-01-01', '01/02/2021', '03-Jan-2021', '2021.04.01',
0183: '05 May 2021'],
0184: ... 'Value': [1, 2, 3, 4, 5]
0185: ... })
0186: >>> df = format_to_datetime(df, 'Date')
0187: >>> print(df.dtypes)
0188: Date datetime64[ns]
0189: Value int64
0190: dtype: object
0191: """
+0192: if date_col not in data.columns:
__Pyx_TraceLine(192,0,__PYX_ERR(0, 192, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_date_col, __pyx_t_1, Py_NE)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 192, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+0193: raise ValueError(f"Column '{date_col}' not found in DataFrame.")
__Pyx_TraceLine(193,0,__PYX_ERR(0, 193, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = 127; __Pyx_INCREF(__pyx_kp_u_Column); __pyx_t_3 += 8; __Pyx_GIVEREF(__pyx_kp_u_Column); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Column); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_date_col, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_4; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_not_found_in_DataFrame); __pyx_t_3 += 25; __Pyx_GIVEREF(__pyx_kp_u_not_found_in_DataFrame); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_not_found_in_DataFrame); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 193, __pyx_L1_error)
0194:
+0195: try:
__Pyx_TraceLine(195,0,__PYX_ERR(0, 195, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L7_except_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; __pyx_L9_try_end:; }
+0196: data[date_col] = pd.to_datetime(data[date_col], **dt_kws)
__Pyx_TraceLine(196,0,__PYX_ERR(0, 196, __pyx_L4_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_to_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_v_date_col); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1)) __PYX_ERR(0, 196, __pyx_L4_error); __pyx_t_1 = 0; __pyx_t_1 = PyDict_Copy(__pyx_v_dt_kws); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely((PyObject_SetItem(__pyx_v_data, __pyx_v_date_col, __pyx_t_10) < 0))) __PYX_ERR(0, 196, __pyx_L4_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0197: if verbose:
__Pyx_TraceLine(197,0,__PYX_ERR(0, 197, __pyx_L4_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 197, __pyx_L4_error) if (__pyx_t_2) { /* … */ }
+0198: print(f"Column '{date_col}' successfully converted to datetime format.")
__Pyx_TraceLine(198,0,__PYX_ERR(0, 198, __pyx_L4_error)) __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 198, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = 0; __pyx_t_4 = 127; __Pyx_INCREF(__pyx_kp_u_Column); __pyx_t_3 += 8; __Pyx_GIVEREF(__pyx_kp_u_Column); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Column); __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_date_col, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_4; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_successfully_converted_to_datet); __pyx_t_3 += 44; __Pyx_GIVEREF(__pyx_kp_u_successfully_converted_to_datet); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_successfully_converted_to_datet); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 198, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+0199: except Exception as e:
__Pyx_TraceLine(199,0,__PYX_ERR(0, 199, __pyx_L6_except_error)) __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_11) { __Pyx_AddTraceback("gofast.tools.coreutils.format_to_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_1, &__pyx_t_9) < 0) __PYX_ERR(0, 199, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; /*try:*/ { /* … */ __Pyx_TraceLine(199,0,__PYX_ERR(0, 199, __pyx_L16_error)) /*finally:*/ { __pyx_L16_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_11 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L6_except_error; } __pyx_L15_return: { __pyx_t_20 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; __pyx_r = __pyx_t_20; __pyx_t_20 = 0; goto __pyx_L7_except_return; } } } goto __pyx_L6_except_error;
+0200: print(f"Error converting '{date_col}' to datetime format: {e}")
__Pyx_TraceLine(200,0,__PYX_ERR(0, 200, __pyx_L16_error)) __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 200, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = 0; __pyx_t_4 = 127; __Pyx_INCREF(__pyx_kp_u_Error_converting); __pyx_t_3 += 18; __Pyx_GIVEREF(__pyx_kp_u_Error_converting); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Error_converting); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_date_col, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 200, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_4; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u_to_datetime_format); __pyx_t_3 += 22; __Pyx_GIVEREF(__pyx_kp_u_to_datetime_format); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_to_datetime_format); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 200, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_4; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_5, 4, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 200, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 200, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0201: return data
__Pyx_TraceLine(201,0,__PYX_ERR(0, 201, __pyx_L16_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L15_return; }
0202:
+0203: return data
__Pyx_TraceLine(203,0,__PYX_ERR(0, 203, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
0204:
+0205: def adjust_to_samples(n_samples, *values, initial_guess=None, error='warn'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_3adjust_to_samples(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_2adjust_to_samples, "\n Adjusts the given values to match a total number of samples, aiming to distribute\n the samples evenly across the dimensions represented by the values. The function\n can adjust even if only one value is given.\n\n Parameters\n ----------\n n_samples : int\n The desired total number of samples.\n *values : int\n Variable length argument list representing the dimensions to adjust.\n initial_guess : float or None, optional\n An initial guess for the adjustment factor. If None, an automatic guess is made.\n error : str, optional\n Error handling strategy ('warn', 'ignore', 'raise'). This parameter is considered\n only when no values or one value is provided.\n\n Returns\n -------\n adjusted_values : tuple\n A tuple of adjusted values, aiming to distribute the total samples evenly.\n If only one value is given, the function tries to adjust it based on the\n total number of samples and the initial guess.\n\n Raises\n ------\n ValueError\n Raised if error is set to 'raise' and no values are provided.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import adjust_to_samples\n >>> adjust_to_samples(1000, 10, 20, initial_guess=5)\n (50, 20)\n\n >>> adjust_to_samples(1000, 10, initial_guess=2)\n (2,)\n\n Notes\n -----\n The function aims to adjust the values to match the desired total number of samples\n as closely as possible. When only one value is given, the function uses the initial\n guess to make an adjustment, respecting the total number of samples.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_3adjust_to_samples = {"adjust_to_samples", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_3adjust_to_samples, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_2adjust_to_samples}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_3adjust_to_samples(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_n_samples = 0; PyObject *__pyx_v_initial_guess = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_values = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("adjust_to_samples (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_values = __Pyx_ArgsSlice_FASTCALL(__pyx_args, 1, __pyx_nargs); if (unlikely(!__pyx_v_values)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_values); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_samples,&__pyx_n_s_initial_guess,&__pyx_n_s_error,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_warn))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n_samples)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args > 0 && likely(kw_args <= 2)) { Py_ssize_t index; for (index = 1; index < 3 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 205, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; const Py_ssize_t used_pos_args = (kwd_pos_args < 1) ? kwd_pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, used_pos_args, "adjust_to_samples") < 0)) __PYX_ERR(0, 205, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_n_samples = values[0]; __pyx_v_initial_guess = values[1]; __pyx_v_error = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("adjust_to_samples", 0, 1, 1, __pyx_nargs); __PYX_ERR(0, 205, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_CLEAR(__pyx_v_values); __Pyx_AddTraceback("gofast.tools.coreutils.adjust_to_samples", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_2adjust_to_samples(__pyx_self, __pyx_v_n_samples, __pyx_v_initial_guess, __pyx_v_error, __pyx_v_values); /* function exit code */ __Pyx_DECREF(__pyx_v_values); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_2adjust_to_samples(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n_samples, PyObject *__pyx_v_initial_guess, PyObject *__pyx_v_error, PyObject *__pyx_v_values) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples *__pyx_cur_scope; PyObject *__pyx_v_message = NULL; PyObject *__pyx_v_single_value = NULL; PyObject *__pyx_v_adjusted_value = NULL; PyObject *__pyx_v_objective = 0; PyObject *__pyx_v_factors_initial = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_adjusted_values = NULL; PyObject *__pyx_7genexpr__pyx_v_value = NULL; CYTHON_UNUSED PyObject *__pyx_8genexpr1__pyx_v__ = NULL; PyObject *__pyx_gb_6gofast_5tools_9coreutils_17adjust_to_samples_4generator3 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__2) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 205, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("adjust_to_samples", __pyx_f[0], 205, 0, __PYX_ERR(0, 205, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_n_samples = __pyx_v_n_samples; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_n_samples); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_n_samples); __pyx_cur_scope->__pyx_v_values = __pyx_v_values; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_values); __Pyx_INCREF(__pyx_v_initial_guess); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.adjust_to_samples", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_message); __Pyx_XDECREF(__pyx_v_single_value); __Pyx_XDECREF(__pyx_v_adjusted_value); __Pyx_XDECREF(__pyx_v_objective); __Pyx_XDECREF(__pyx_v_factors_initial); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_adjusted_values); __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value); __Pyx_XDECREF(__pyx_8genexpr1__pyx_v__); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_17adjust_to_samples_4generator3); __Pyx_XDECREF(__pyx_v_initial_guess); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__353 = PyTuple_Pack(16, __pyx_n_s_n_samples, __pyx_n_s_initial_guess, __pyx_n_s_error, __pyx_n_s_values, __pyx_n_s_message, __pyx_n_s_single_value, __pyx_n_s_adjusted_value, __pyx_n_s_objective, __pyx_n_s_objective, __pyx_n_s_factors_initial, __pyx_n_s_result, __pyx_n_s_adjusted_values, __pyx_n_s_value, __pyx_n_s__8, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__353)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__353); __Pyx_GIVEREF(__pyx_tuple__353); /* … */ __Pyx_TraceLine(205,0,__PYX_ERR(0, 205, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_initial_guess, Py_None) < 0) __PYX_ERR(0, 205, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_error, ((PyObject*)__pyx_n_u_warn)) < 0) __PYX_ERR(0, 205, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_3adjust_to_samples, 0, __pyx_n_s_adjust_to_samples, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__2)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_adjust_to_samples, __pyx_t_2) < 0) __PYX_ERR(0, 205, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__353, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_adjust_to_samples, 205, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 205, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples { PyObject_HEAD PyObject *__pyx_v_n_samples; PyObject *__pyx_v_values; };
0206: """
0207: Adjusts the given values to match a total number of samples, aiming to distribute
0208: the samples evenly across the dimensions represented by the values. The function
0209: can adjust even if only one value is given.
0210:
0211: Parameters
0212: ----------
0213: n_samples : int
0214: The desired total number of samples.
0215: *values : int
0216: Variable length argument list representing the dimensions to adjust.
0217: initial_guess : float or None, optional
0218: An initial guess for the adjustment factor. If None, an automatic guess is made.
0219: error : str, optional
0220: Error handling strategy ('warn', 'ignore', 'raise'). This parameter is considered
0221: only when no values or one value is provided.
0222:
0223: Returns
0224: -------
0225: adjusted_values : tuple
0226: A tuple of adjusted values, aiming to distribute the total samples evenly.
0227: If only one value is given, the function tries to adjust it based on the
0228: total number of samples and the initial guess.
0229:
0230: Raises
0231: ------
0232: ValueError
0233: Raised if error is set to 'raise' and no values are provided.
0234:
0235: Examples
0236: --------
0237: >>> from gofast.tools.coreutils import adjust_to_samples
0238: >>> adjust_to_samples(1000, 10, 20, initial_guess=5)
0239: (50, 20)
0240:
0241: >>> adjust_to_samples(1000, 10, initial_guess=2)
0242: (2,)
0243:
0244: Notes
0245: -----
0246: The function aims to adjust the values to match the desired total number of samples
0247: as closely as possible. When only one value is given, the function uses the initial
0248: guess to make an adjustment, respecting the total number of samples.
0249: """
+0250: if len(values) == 0:
__Pyx_TraceLine(250,0,__PYX_ERR(0, 250, __pyx_L1_error)) __pyx_t_1 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 250, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 == 0); if (__pyx_t_3) { /* … */ }
+0251: message = "No values provided for adjustment."
__Pyx_TraceLine(251,0,__PYX_ERR(0, 251, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_No_values_provided_for_adjustmen); __pyx_v_message = __pyx_kp_u_No_values_provided_for_adjustmen;
+0252: if error == 'raise':
__Pyx_TraceLine(252,0,__PYX_ERR(0, 252, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 252, __pyx_L1_error) if (unlikely(__pyx_t_3)) { /* … */ }
+0253: raise ValueError(message)
__Pyx_TraceLine(253,0,__PYX_ERR(0, 253, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 253, __pyx_L1_error)
+0254: elif error == 'warn':
__Pyx_TraceLine(254,0,__PYX_ERR(0, 254, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_warn, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 254, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+0255: warnings.warn(message)
__Pyx_TraceLine(255,0,__PYX_ERR(0, 255, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_message}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0256: return ()
__Pyx_TraceLine(256,0,__PYX_ERR(0, 256, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_empty_tuple); __pyx_r = __pyx_empty_tuple; goto __pyx_L0;
0257:
+0258: if len(values) == 1:
__Pyx_TraceLine(258,0,__PYX_ERR(0, 258, __pyx_L1_error)) __pyx_t_1 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 258, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 == 1); if (__pyx_t_3) { /* … */ }
0259: # If only one value is given, adjust it based on initial guess and n_samples
+0260: single_value = values[0]
__Pyx_TraceLine(260,0,__PYX_ERR(0, 260, __pyx_L1_error)) __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_values, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_single_value = __pyx_t_1; __pyx_t_1 = 0;
+0261: adjusted_value = n_samples // single_value if initial_guess is None else initial_guess
__Pyx_TraceLine(261,0,__PYX_ERR(0, 261, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_initial_guess == Py_None); if (__pyx_t_3) { __pyx_t_5 = PyNumber_FloorDivide(__pyx_cur_scope->__pyx_v_n_samples, __pyx_v_single_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; } else { __Pyx_INCREF(__pyx_v_initial_guess); __pyx_t_1 = __pyx_v_initial_guess; } __pyx_v_adjusted_value = __pyx_t_1; __pyx_t_1 = 0;
+0262: return (adjusted_value,)
__Pyx_TraceLine(262,0,__PYX_ERR(0, 262, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_adjusted_value); __Pyx_GIVEREF(__pyx_v_adjusted_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_adjusted_value)) __PYX_ERR(0, 262, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0263:
+0264: if initial_guess is None:
__Pyx_TraceLine(264,0,__PYX_ERR(0, 264, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_initial_guess == Py_None); if (__pyx_t_3) { /* … */ }
+0265: initial_guess = np.mean(values)
__Pyx_TraceLine(265,0,__PYX_ERR(0, 265, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_mean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_values}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_initial_guess, __pyx_t_1); __pyx_t_1 = 0;
0266:
0267: # Function to minimize: difference between product of adjusted values and n_samples
+0268: def objective(factors):
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_17adjust_to_samples_1objective(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_17adjust_to_samples_1objective = {"objective", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_17adjust_to_samples_1objective, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_17adjust_to_samples_1objective(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_factors = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("objective (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_factors,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_factors)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "objective") < 0)) __PYX_ERR(0, 268, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_factors = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("objective", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 268, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.adjust_to_samples.objective", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_17adjust_to_samples_objective(__pyx_self, __pyx_v_factors);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_17adjust_to_samples_objective(PyObject *__pyx_self, PyObject *__pyx_v_factors) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples *__pyx_outer_scope;
PyObject *__pyx_v_prod = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct__adjust_to_samples *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("objective", __pyx_f[0], 268, 0, __PYX_ERR(0, 268, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("gofast.tools.coreutils.adjust_to_samples.objective", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_prod);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_17adjust_to_samples_4generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
/* … */
__pyx_tuple__3 = PyTuple_Pack(2, __pyx_n_s_factors, __pyx_n_s_prod); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 268, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__3);
__Pyx_GIVEREF(__pyx_tuple__3);
/* … */
__Pyx_TraceLine(268,0,__PYX_ERR(0, 268, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_17adjust_to_samples_1objective, 0, __pyx_n_s_adjust_to_samples_locals_objecti, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_objective = __pyx_t_1;
__pyx_t_1 = 0;
__pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_objective, 268, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 268, __pyx_L1_error)
+0269: prod = np.prod(np.array(values) * factors)
__Pyx_TraceLine(269,0,__PYX_ERR(0, 269, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_prod); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_cur_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 269, __pyx_L1_error) } __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_values}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = PyNumber_Multiply(__pyx_t_2, __pyx_v_factors); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_prod = __pyx_t_1; __pyx_t_1 = 0;
+0270: return abs(prod - n_samples)
__Pyx_TraceLine(270,0,__PYX_ERR(0, 270, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_cur_scope->__pyx_v_n_samples)) { __Pyx_RaiseClosureNameError("n_samples"); __PYX_ERR(0, 270, __pyx_L1_error) } __pyx_t_1 = PyNumber_Subtract(__pyx_v_prod, __pyx_cur_scope->__pyx_v_n_samples); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyNumber_Absolute(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
0271:
0272: # Start with initial guesses for factors
+0273: factors_initial = [initial_guess / value for value in values]
__Pyx_TraceLine(273,0,__PYX_ERR(0, 273, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 273, __pyx_L9_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 273, __pyx_L9_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 273, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_value, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_v_initial_guess, __pyx_7genexpr__pyx_v_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 273, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 273, __pyx_L9_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value); __pyx_7genexpr__pyx_v_value = 0; goto __pyx_L13_exit_scope; __pyx_L9_error:; __Pyx_XDECREF(__pyx_7genexpr__pyx_v_value); __pyx_7genexpr__pyx_v_value = 0; goto __pyx_L1_error; __pyx_L13_exit_scope:; } /* exit inner scope */ __pyx_v_factors_initial = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0274: result = optimize_minimize(objective, factors_initial, bounds=[(0, None) for _ in values])
__Pyx_TraceLine(274,0,__PYX_ERR(0, 274, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_optimize_minimize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_objective); __Pyx_GIVEREF(__pyx_v_objective); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_objective)) __PYX_ERR(0, 274, __pyx_L1_error); __Pyx_INCREF(__pyx_v_factors_initial); __Pyx_GIVEREF(__pyx_v_factors_initial); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_factors_initial)) __PYX_ERR(0, 274, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); { /* enter inner scope */ __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 274, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_8); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 274, __pyx_L16_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_2); __Pyx_INCREF(__pyx_t_9); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 274, __pyx_L16_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 274, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v__, __pyx_t_9); __pyx_t_9 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_tuple__5))) __PYX_ERR(0, 274, __pyx_L16_error) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v__); __pyx_8genexpr1__pyx_v__ = 0; goto __pyx_L20_exit_scope; __pyx_L16_error:; __Pyx_XDECREF(__pyx_8genexpr1__pyx_v__); __pyx_8genexpr1__pyx_v__ = 0; goto __pyx_L1_error; __pyx_L20_exit_scope:; } /* exit inner scope */ if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_bounds, __pyx_t_7) < 0) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_result = __pyx_t_7; __pyx_t_7 = 0; /* … */ __pyx_tuple__5 = PyTuple_Pack(2, __pyx_int_0, Py_None); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 274, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5);
0275:
+0276: if result.success:
__Pyx_TraceLine(276,0,__PYX_ERR(0, 276, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_success); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 276, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L21; }
0277: adjusted_values = (
+0278: tuple(max(1, int(round(value * factor)))
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_17adjust_to_samples_2genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_1_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_1_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_1_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 278, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_17adjust_to_samples_4generator3, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_adjust_to_samples_locals_genexpr, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.adjust_to_samples.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_17adjust_to_samples_4generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 278, __pyx_L1_error)
/* … */
__Pyx_TraceLine(278,0,__PYX_ERR(0, 278, __pyx_L1_error))
__pyx_t_4 = PyNumber_Multiply(__pyx_cur_scope->__pyx_v_value, __pyx_cur_scope->__pyx_v_factor); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_round, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__pyx_t_9 = 1;
__pyx_t_5 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_7 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
if (__pyx_t_10) {
__Pyx_INCREF(__pyx_t_4);
__pyx_t_6 = __pyx_t_4;
} else {
__pyx_t_7 = __Pyx_PyInt_From_long(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_6 = __pyx_t_7;
__pyx_t_7 = 0;
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_INCREF(__pyx_t_6);
__pyx_r = __pyx_t_6;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_XGIVEREF(__pyx_t_1);
__pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
__pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
__pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
/* return from generator, yielding value */
__pyx_generator->resume_label = 1;
return __pyx_r;
__pyx_L8_resume_from_yield:;
__pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
__pyx_cur_scope->__pyx_t_0 = 0;
__Pyx_XGOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
__pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 278, __pyx_L1_error)
/* … */
/* function exit code */
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(278,0,__PYX_ERR(0, 278, __pyx_L1_error))
__pyx_t_5 = __pyx_pf_6gofast_5tools_9coreutils_17adjust_to_samples_2genexpr(NULL, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PySequence_Tuple(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_v_adjusted_values = ((PyObject*)__pyx_t_7);
__pyx_t_7 = 0;
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_1_genexpr {
PyObject_HEAD
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_factor;
PyObject *__pyx_v_value;
PyObject *__pyx_t_0;
Py_ssize_t __pyx_t_1;
PyObject *(*__pyx_t_2)(PyObject *);
};
+0279: for value, factor in zip(values, result.x))
__Pyx_TraceLine(279,0,__PYX_ERR(0, 279, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 279, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 279, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 279, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 279, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 279, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 279, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 279, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 279, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 279, __pyx_L1_error) __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_value); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_value, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_factor); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_factor, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __Pyx_TraceLine(279,0,__PYX_ERR(0, 279, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* … */ __Pyx_TraceLine(279,0,__PYX_ERR(0, 279, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_result, __pyx_n_s_x); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_values); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_cur_scope->__pyx_v_values)) __PYX_ERR(0, 279, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7)) __PYX_ERR(0, 279, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
0280: )
0281: else:
+0282: adjusted_values = values # Fallback to original values if optimization fails
__Pyx_TraceLine(282,0,__PYX_ERR(0, 282, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values); __pyx_v_adjusted_values = __pyx_cur_scope->__pyx_v_values; } __pyx_L21:;
0283:
+0284: return adjusted_values
__Pyx_TraceLine(284,0,__PYX_ERR(0, 284, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_adjusted_values); __pyx_r = __pyx_v_adjusted_values; goto __pyx_L0;
0285:
+0286: def unpack_list_of_dicts(list_of_dicts):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_5unpack_list_of_dicts(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_4unpack_list_of_dicts, "\n Unpacks a list of dictionaries into a single dictionary,\n merging all keys and values.\n\n Parameters:\n ----------\n list_of_dicts : list of dicts\n A list where each element is a dictionary with a single key-value pair, \n the value being a list.\n\n Returns:\n -------\n dict\n A single dictionary with all keys from the original list of dictionaries, \n each associated with its combined list of values from all occurrences \n of the key.\n\n Example:\n --------\n >>> from gofast.tools.coreutils import unpack_list_of_dicts\n >>> list_of_dicts = [\n {'key1': ['value10', 'value11']},\n {'key2': ['value20', 'value21']},\n {'key1': ['value12']},\n {'key2': ['value22']}\n ]\n >>> unpacked_dict = unpack_list_of_dicts(list_of_dicts)\n >>> print(unpacked_dict)\n {'key1': ['value10', 'value11', 'value12'], 'key2': ['value20', 'value21', 'value22']}\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_5unpack_list_of_dicts = {"unpack_list_of_dicts", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_5unpack_list_of_dicts, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_4unpack_list_of_dicts}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_5unpack_list_of_dicts(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_list_of_dicts = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("unpack_list_of_dicts (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_list_of_dicts,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_list_of_dicts)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "unpack_list_of_dicts") < 0)) __PYX_ERR(0, 286, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_list_of_dicts = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("unpack_list_of_dicts", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 286, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.unpack_list_of_dicts", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_4unpack_list_of_dicts(__pyx_self, __pyx_v_list_of_dicts); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_4unpack_list_of_dicts(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_of_dicts) { PyObject *__pyx_v_unpacked_dict = NULL; PyObject *__pyx_v_single_dict = NULL; PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_values = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__6) __Pyx_TraceCall("unpack_list_of_dicts", __pyx_f[0], 286, 0, __PYX_ERR(0, 286, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.unpack_list_of_dicts", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_unpacked_dict); __Pyx_XDECREF(__pyx_v_single_dict); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_values); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__354 = PyTuple_Pack(5, __pyx_n_s_list_of_dicts, __pyx_n_s_unpacked_dict, __pyx_n_s_single_dict, __pyx_n_s_key, __pyx_n_s_values); if (unlikely(!__pyx_tuple__354)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__354); __Pyx_GIVEREF(__pyx_tuple__354); /* … */ __Pyx_TraceLine(286,0,__PYX_ERR(0, 286, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_5unpack_list_of_dicts, 0, __pyx_n_s_unpack_list_of_dicts, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_unpack_list_of_dicts, __pyx_t_2) < 0) __PYX_ERR(0, 286, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__354, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_unpack_list_of_dicts, 286, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 286, __pyx_L1_error)
0287: """
0288: Unpacks a list of dictionaries into a single dictionary,
0289: merging all keys and values.
0290:
0291: Parameters:
0292: ----------
0293: list_of_dicts : list of dicts
0294: A list where each element is a dictionary with a single key-value pair,
0295: the value being a list.
0296:
0297: Returns:
0298: -------
0299: dict
0300: A single dictionary with all keys from the original list of dictionaries,
0301: each associated with its combined list of values from all occurrences
0302: of the key.
0303:
0304: Example:
0305: --------
0306: >>> from gofast.tools.coreutils import unpack_list_of_dicts
0307: >>> list_of_dicts = [
0308: {'key1': ['value10', 'value11']},
0309: {'key2': ['value20', 'value21']},
0310: {'key1': ['value12']},
0311: {'key2': ['value22']}
0312: ]
0313: >>> unpacked_dict = unpack_list_of_dicts(list_of_dicts)
0314: >>> print(unpacked_dict)
0315: {'key1': ['value10', 'value11', 'value12'], 'key2': ['value20', 'value21', 'value22']}
0316: """
+0317: unpacked_dict = defaultdict(list)
__Pyx_TraceLine(317,0,__PYX_ERR(0, 317, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_defaultdict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, ((PyObject *)(&PyList_Type))}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_unpacked_dict = __pyx_t_1; __pyx_t_1 = 0;
+0318: for single_dict in list_of_dicts:
__Pyx_TraceLine(318,0,__PYX_ERR(0, 318, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_list_of_dicts)) || PyTuple_CheckExact(__pyx_v_list_of_dicts)) { __pyx_t_1 = __pyx_v_list_of_dicts; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_list_of_dicts); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 318, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 318, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 318, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 318, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 318, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_6(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 318, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_single_dict, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(318,0,__PYX_ERR(0, 318, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0319: for key, values in single_dict.items():
__Pyx_TraceLine(319,0,__PYX_ERR(0, 319, __pyx_L1_error)) __pyx_t_7 = 0; if (unlikely(__pyx_v_single_dict == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 319, __pyx_L1_error) } __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_single_dict, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; while (1) { __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_8, &__pyx_t_7, &__pyx_t_3, &__pyx_t_9, NULL, __pyx_t_4); if (unlikely(__pyx_t_10 == 0)) break; if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_values, __pyx_t_9); __pyx_t_9 = 0;
+0320: unpacked_dict[key].extend(values)
__Pyx_TraceLine(320,0,__PYX_ERR(0, 320, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_unpacked_dict, __pyx_v_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_extend); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_values}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0321: return dict(unpacked_dict) # Convert defaultdict back to dict if required
__Pyx_TraceLine(321,0,__PYX_ERR(0, 321, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_v_unpacked_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0322:
+0323: def get_params (obj: object ) -> dict:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7get_params(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_6get_params, "\n Get object parameters. \n \n Object can be callable or instances \n \n :param obj: object , can be callable or instance \n \n :return: dict of parameters values \n \n :examples: \n >>> from sklearn.svm import SVC \n >>> from gofast.tools.coreutils import get_params \n >>> sigmoid= SVC (\n **{\n 'C': 512.0,\n 'coef0': 0,\n 'degree': 1,\n 'gamma': 0.001953125,\n 'kernel': 'sigmoid',\n 'tol': 1.0 \n }\n )\n >>> pvalues = get_params( sigmoid)\n >>> {'decision_function_shape': 'ovr',\n 'break_ties': False,\n 'kernel': 'sigmoid',\n 'degree': 1,\n 'gamma': 0.001953125,\n 'coef0': 0,\n 'tol': 1.0,\n 'C': 512.0,\n 'nu': 0.0,\n 'epsilon': 0.0,\n 'shrinking': True,\n 'probability': False,\n 'cache_size': 200,\n 'class_weight': None,\n 'verbose': False,\n 'max_iter': -1,\n 'random_state': None\n }\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_7get_params = {"get_params", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_7get_params, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_6get_params}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7get_params(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_params (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 323, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_params") < 0)) __PYX_ERR(0, 323, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_params", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 323, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_params", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_6get_params(__pyx_self, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_6get_params(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) { PyObject *__pyx_v_cls_or_func_signature = NULL; PyObject *__pyx_v_PARAMS_VALUES = NULL; PyObject *__pyx_8genexpr3__pyx_v_k = NULL; PyObject *__pyx_8genexpr3__pyx_v_v = NULL; PyObject *__pyx_8genexpr4__pyx_v_k = NULL; PyObject *__pyx_8genexpr4__pyx_v_v = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__7) __Pyx_TraceCall("get_params", __pyx_f[0], 323, 0, __PYX_ERR(0, 323, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.get_params", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cls_or_func_signature); __Pyx_XDECREF(__pyx_v_PARAMS_VALUES); __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_v); __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_v); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__355 = PyTuple_Pack(7, __pyx_n_s_obj, __pyx_n_s_cls_or_func_signature, __pyx_n_s_PARAMS_VALUES, __pyx_n_s_k, __pyx_n_s_v, __pyx_n_s_k, __pyx_n_s_v); if (unlikely(!__pyx_tuple__355)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__355); __Pyx_GIVEREF(__pyx_tuple__355); /* … */ __Pyx_TraceLine(323,0,__PYX_ERR(0, 323, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_obj, __pyx_n_s_object) < 0) __PYX_ERR(0, 323, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_dict_2) < 0) __PYX_ERR(0, 323, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_7get_params, 0, __pyx_n_s_get_params, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_params, __pyx_t_4) < 0) __PYX_ERR(0, 323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__355, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_params, 323, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 323, __pyx_L1_error)
0324: """
0325: Get object parameters.
0326:
0327: Object can be callable or instances
0328:
0329: :param obj: object , can be callable or instance
0330:
0331: :return: dict of parameters values
0332:
0333: :examples:
0334: >>> from sklearn.svm import SVC
0335: >>> from gofast.tools.coreutils import get_params
0336: >>> sigmoid= SVC (
0337: **{
0338: 'C': 512.0,
0339: 'coef0': 0,
0340: 'degree': 1,
0341: 'gamma': 0.001953125,
0342: 'kernel': 'sigmoid',
0343: 'tol': 1.0
0344: }
0345: )
0346: >>> pvalues = get_params( sigmoid)
0347: >>> {'decision_function_shape': 'ovr',
0348: 'break_ties': False,
0349: 'kernel': 'sigmoid',
0350: 'degree': 1,
0351: 'gamma': 0.001953125,
0352: 'coef0': 0,
0353: 'tol': 1.0,
0354: 'C': 512.0,
0355: 'nu': 0.0,
0356: 'epsilon': 0.0,
0357: 'shrinking': True,
0358: 'probability': False,
0359: 'cache_size': 200,
0360: 'class_weight': None,
0361: 'verbose': False,
0362: 'max_iter': -1,
0363: 'random_state': None
0364: }
0365: """
+0366: if hasattr (obj, '__call__'):
__Pyx_TraceLine(366,0,__PYX_ERR(0, 366, __pyx_L1_error)) __pyx_t_1 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_call); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 366, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+0367: cls_or_func_signature = inspect.signature(obj)
__Pyx_TraceLine(367,0,__PYX_ERR(0, 367, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_inspect); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_signature); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_obj}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_cls_or_func_signature = __pyx_t_2; __pyx_t_2 = 0;
+0368: PARAMS_VALUES = {k: None if v.default is (inspect.Parameter.empty
__Pyx_TraceLine(368,0,__PYX_ERR(0, 368, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 368, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(368,0,__PYX_ERR(0, 368, __pyx_L6_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr3__pyx_v_v, __pyx_n_s_default); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 368, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); /* … */ __Pyx_TraceLine(369,0,__PYX_ERR(0, 369, __pyx_L6_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_inspect); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 368, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); /* … */ __Pyx_TraceLine(368,0,__PYX_ERR(0, 368, __pyx_L6_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 368, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 368, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 368, __pyx_L6_error) if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { __Pyx_INCREF(__pyx_t_11); __pyx_t_10 = __pyx_t_11; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L9_bool_binop_done; } /* … */ __Pyx_TraceLine(368,0,__PYX_ERR(0, 368, __pyx_L6_error)) __Pyx_INCREF(Py_None); __pyx_t_3 = Py_None; } else {
+0369: or ...) else v.default
__Pyx_TraceLine(369,0,__PYX_ERR(0, 369, __pyx_L6_error)) __Pyx_INCREF(Py_Ellipsis); __pyx_t_10 = Py_Ellipsis; __pyx_L9_bool_binop_done:; __pyx_t_1 = (__pyx_t_8 == __pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_1) { /* … */ __Pyx_TraceLine(369,0,__PYX_ERR(0, 369, __pyx_L6_error)) __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr3__pyx_v_v, __pyx_n_s_default); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 369, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __pyx_t_10; __pyx_t_10 = 0; } if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_8genexpr3__pyx_v_k, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 368, __pyx_L6_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_k); __pyx_8genexpr3__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_v); __pyx_8genexpr3__pyx_v_v = 0; goto __pyx_L11_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_k); __pyx_8genexpr3__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_v); __pyx_8genexpr3__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L11_exit_scope:; } /* exit inner scope */ __pyx_v_PARAMS_VALUES = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+0370: for k, v in cls_or_func_signature.parameters.items()
__Pyx_TraceLine(370,0,__PYX_ERR(0, 370, __pyx_L6_error)) __pyx_t_6 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls_or_func_signature, __pyx_n_s_parameters); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__pyx_t_3 == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 370, __pyx_L6_error) } __pyx_t_8 = __Pyx_dict_iterator(__pyx_t_3, 0, __pyx_n_s_items, (&__pyx_t_7), (&__pyx_t_5)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 370, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = __pyx_t_8; __pyx_t_8 = 0; while (1) { __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_7, &__pyx_t_6, &__pyx_t_8, &__pyx_t_3, NULL, __pyx_t_5); if (unlikely(__pyx_t_9 == 0)) break; if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 370, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_k, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0;
0371: # if v.default is not inspect.Parameter.empty
0372: }
+0373: elif hasattr(obj, '__dict__'):
__Pyx_TraceLine(373,0,__PYX_ERR(0, 373, __pyx_L1_error)) __pyx_t_1 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_dict); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 373, __pyx_L1_error) if (__pyx_t_1) { /* … */ } __pyx_L3:;
+0374: PARAMS_VALUES = {k:v for k, v in obj.__dict__.items()
__Pyx_TraceLine(374,0,__PYX_ERR(0, 374, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 374, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 374, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(__pyx_t_3 == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 374, __pyx_L14_error) } __pyx_t_10 = __Pyx_dict_iterator(__pyx_t_3, 0, __pyx_n_s_items, (&__pyx_t_6), (&__pyx_t_5)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 374, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = __pyx_t_10; __pyx_t_10 = 0; while (1) { __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_6, &__pyx_t_7, &__pyx_t_10, &__pyx_t_3, NULL, __pyx_t_5); if (unlikely(__pyx_t_9 == 0)) break; if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 374, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_k, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(374,0,__PYX_ERR(0, 374, __pyx_L14_error)) if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_8genexpr4__pyx_v_k, (PyObject*)__pyx_8genexpr4__pyx_v_v))) __PYX_ERR(0, 374, __pyx_L14_error)
+0375: if not (k.endswith('_') or k.startswith('_'))}
__Pyx_TraceLine(375,0,__PYX_ERR(0, 375, __pyx_L14_error)) __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr4__pyx_v_k, __pyx_n_s_endswith); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 375, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_n_u__8}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 375, __pyx_L14_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_13) { } else { __pyx_t_1 = __pyx_t_13; goto __pyx_L18_bool_binop_done; } __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr4__pyx_v_k, __pyx_n_s_startswith); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 375, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_n_u__8}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 375, __pyx_L14_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_13; __pyx_L18_bool_binop_done:; __pyx_t_13 = (!__pyx_t_1); if (__pyx_t_13) { /* … */ } } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_k); __pyx_8genexpr4__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_v); __pyx_8genexpr4__pyx_v_v = 0; goto __pyx_L20_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_k); __pyx_8genexpr4__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_v); __pyx_8genexpr4__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L20_exit_scope:; } /* exit inner scope */ __pyx_v_PARAMS_VALUES = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
0376:
+0377: return PARAMS_VALUES
__Pyx_TraceLine(377,0,__PYX_ERR(0, 377, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 377, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_PARAMS_VALUES); __pyx_r = __pyx_v_PARAMS_VALUES; goto __pyx_L0;
0378:
+0379: def is_classification_task(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_9is_classification_task(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_8is_classification_task, "\n Check whether the given arrays are for a classification task.\n\n This function assumes that if all values in the provided arrays are \n integers and the number of unique values is within the specified\n threshold, it is a classification task.\n\n Parameters\n ----------\n *y : list or numpy.array\n A variable number of arrays representing actual values, \n predicted values, etc.\n max_unique_values : int, optional\n The maximum number of unique values to consider the task \n as classification. \n Default is 10.\n\n Returns\n -------\n bool\n True if the provided arrays are for a classification task, \n False otherwise.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import is_classification_task \n >>> y_true = [0, 1, 1, 0, 1]\n >>> y_pred = [0, 1, 0, 0, 1]\n >>> is_classification_task(y_true, y_pred)\n True\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_9is_classification_task = {"is_classification_task", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_9is_classification_task, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_8is_classification_task}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_9is_classification_task(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_max_unique_values = 0; PyObject *__pyx_v_y = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_classification_task (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_y = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_max_unique_values,0}; PyObject* values[1] = {0}; values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)__pyx_int_10))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args == 1) { const Py_ssize_t index = 0; PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 379, __pyx_L3_error) } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "is_classification_task") < 0)) __PYX_ERR(0, 379, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_max_unique_values = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_classification_task", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 379, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_y); __pyx_v_y = 0; __Pyx_AddTraceback("gofast.tools.coreutils.is_classification_task", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_8is_classification_task(__pyx_self, __pyx_v_max_unique_values, __pyx_v_y); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_DECREF(__pyx_v_y); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_22is_classification_task_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_8is_classification_task(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_max_unique_values, PyObject *__pyx_v_y) { PyObject *__pyx_v_combined = NULL; PyObject *__pyx_v_unique_values = NULL; PyObject *__pyx_gb_6gofast_5tools_9coreutils_22is_classification_task_2generator4 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__9) __Pyx_TraceCall("is_classification_task", __pyx_f[0], 379, 0, __PYX_ERR(0, 379, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_max_unique_values); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.is_classification_task", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_combined); __Pyx_XDECREF(__pyx_v_unique_values); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_22is_classification_task_2generator4); __Pyx_XDECREF(__pyx_v_max_unique_values); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__356 = PyTuple_Pack(6, __pyx_n_s_max_unique_values, __pyx_n_s_y_4, __pyx_n_s_combined, __pyx_n_s_unique_values, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__356)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__356); __Pyx_GIVEREF(__pyx_tuple__356); /* … */ __Pyx_TraceLine(379,0,__PYX_ERR(0, 379, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_max_unique_values, ((PyObject *)__pyx_int_10)) < 0) __PYX_ERR(0, 379, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_9is_classification_task, 0, __pyx_n_s_is_classification_task, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__9)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_classification_task, __pyx_t_2) < 0) __PYX_ERR(0, 379, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__356, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_classification_task, 379, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 379, __pyx_L1_error)
0380: *y, max_unique_values=10
0381: ):
0382: """
0383: Check whether the given arrays are for a classification task.
0384:
0385: This function assumes that if all values in the provided arrays are
0386: integers and the number of unique values is within the specified
0387: threshold, it is a classification task.
0388:
0389: Parameters
0390: ----------
0391: *y : list or numpy.array
0392: A variable number of arrays representing actual values,
0393: predicted values, etc.
0394: max_unique_values : int, optional
0395: The maximum number of unique values to consider the task
0396: as classification.
0397: Default is 10.
0398:
0399: Returns
0400: -------
0401: bool
0402: True if the provided arrays are for a classification task,
0403: False otherwise.
0404:
0405: Examples
0406: --------
0407: >>> from gofast.tools.coreutils import is_classification_task
0408: >>> y_true = [0, 1, 1, 0, 1]
0409: >>> y_pred = [0, 1, 0, 0, 1]
0410: >>> is_classification_task(y_true, y_pred)
0411: True
0412: """
+0413: max_unique_values = int (
__Pyx_TraceLine(413,0,__PYX_ERR(0, 413, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_max_unique_values, __pyx_t_3); __pyx_t_3 = 0;
+0414: _assert_all_types(max_unique_values,
__Pyx_TraceLine(414,0,__PYX_ERR(0, 414, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(415,0,__PYX_ERR(0, 415, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_max_unique_values); __Pyx_GIVEREF(__pyx_v_max_unique_values); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_max_unique_values)) __PYX_ERR(0, 414, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 414, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 414, __pyx_L1_error); /* … */ __Pyx_TraceLine(414,0,__PYX_ERR(0, 414, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0415: int, float, objname="Max Unique values")
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_objname, __pyx_kp_u_Max_Unique_values) < 0) __PYX_ERR(0, 415, __pyx_L1_error)
0416: )
0417: # Combine all arrays for analysis
+0418: combined = np.concatenate(y)
__Pyx_TraceLine(418,0,__PYX_ERR(0, 418, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_y}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_combined = __pyx_t_3; __pyx_t_3 = 0;
0419:
0420: # Check if all elements are integers
+0421: if (
__Pyx_TraceLine(421,0,__PYX_ERR(0, 421, __pyx_L1_error)) if (__pyx_t_6) { /* … */ }
+0422: not all(isinstance(x, int) for x in combined)
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_22is_classification_task_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_2_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_2_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_2_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_2_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 422, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_22is_classification_task_2generator4, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_is_classification_task_locals_ge, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.is_classification_task.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_22is_classification_task_2generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 422, __pyx_L1_error)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 422, __pyx_L1_error) }
if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
__pyx_t_3 = NULL;
} else {
__pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_3)) {
if (likely(PyList_CheckExact(__pyx_t_1))) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 422, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 422, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
} else {
{
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 422, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 422, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
}
} else {
__pyx_t_4 = __pyx_t_3(__pyx_t_1);
if (unlikely(!__pyx_t_4)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(0, 422, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_4);
}
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_x);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_x, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_5 = PyInt_Check(__pyx_cur_scope->__pyx_v_x);
__pyx_t_6 = (!__pyx_t_5);
if (__pyx_t_6) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(422,0,__PYX_ERR(0, 422, __pyx_L1_error))
__pyx_t_3 = __pyx_pf_6gofast_5tools_9coreutils_22is_classification_task_genexpr(NULL, __pyx_v_combined); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = __Pyx_Generator_Next(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 422, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_8 = (!__pyx_t_7);
if (__pyx_t_8) {
} else {
__pyx_t_6 = __pyx_t_8;
goto __pyx_L4_bool_binop_done;
}
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_2_genexpr {
PyObject_HEAD
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_x;
};
+0423: and not combined.dtype.kind in 'iu'
__Pyx_TraceLine(423,0,__PYX_ERR(0, 423, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_combined, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_kind); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = (__Pyx_PyUnicode_ContainsTF(__pyx_t_3, __pyx_n_u_iu, Py_NE)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __pyx_t_8; __pyx_L4_bool_binop_done:;
0424: ):
+0425: return False
__Pyx_TraceLine(425,0,__PYX_ERR(0, 425, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
0426:
0427: # Check the number of unique elements
+0428: unique_values = np.unique(combined)
__Pyx_TraceLine(428,0,__PYX_ERR(0, 428, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_unique); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_combined}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_unique_values = __pyx_t_3; __pyx_t_3 = 0;
0429: # check Arbitrary threshold for number of classes
+0430: if len(unique_values) > max_unique_values:
__Pyx_TraceLine(430,0,__PYX_ERR(0, 430, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_unique_values); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 430, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_max_unique_values, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 430, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { /* … */ }
+0431: return False
__Pyx_TraceLine(431,0,__PYX_ERR(0, 431, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
0432:
+0433: return True
__Pyx_TraceLine(433,0,__PYX_ERR(0, 433, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
0434:
+0435: def fancy_printer(result, report_name='Data Quality Check Report'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fancy_printer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_10fancy_printer, " \n This _fancy_print function within the check_data_quality function \n iterates over the results dictionary and prints each category \n (like missing data, outliers, etc.) in a formatted manner. It only \n displays categories with findings, making the output more concise and \n focused on the areas that need attention. The use of .title() \n and .replace('_', ' ') methods enhances the readability of the \n category names.\n\n Parameters \n -----------\n result: dict,\n the result to print. Must contain a dictionnary. \n report_name: str, \n A report to fancy printer. \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fancy_printer = {"fancy_printer", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_11fancy_printer, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_10fancy_printer}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fancy_printer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_result = 0; PyObject *__pyx_v_report_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fancy_printer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_result,&__pyx_n_s_report_name,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u_Data_Quality_Check_Report))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_result)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 435, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_report_name); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 435, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "fancy_printer") < 0)) __PYX_ERR(0, 435, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_result = values[0]; __pyx_v_report_name = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fancy_printer", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 435, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.fancy_printer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_10fancy_printer(__pyx_self, __pyx_v_result, __pyx_v_report_name); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_10fancy_printer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_result, PyObject *__pyx_v_report_name) { PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_v_sub_key = NULL; PyObject *__pyx_v_sub_value = NULL; PyObject *__pyx_v_formatted_key = NULL; PyObject *__pyx_v_formatted_value = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__10) __Pyx_TraceCall("fancy_printer", __pyx_f[0], 435, 0, __PYX_ERR(0, 435, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_AddTraceback("gofast.tools.coreutils.fancy_printer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_sub_key); __Pyx_XDECREF(__pyx_v_sub_value); __Pyx_XDECREF(__pyx_v_formatted_key); __Pyx_XDECREF(__pyx_v_formatted_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__357 = PyTuple_Pack(8, __pyx_n_s_result, __pyx_n_s_report_name, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_sub_key, __pyx_n_s_sub_value, __pyx_n_s_formatted_key, __pyx_n_s_formatted_value); if (unlikely(!__pyx_tuple__357)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__357); __Pyx_GIVEREF(__pyx_tuple__357); __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__357, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fancy_printer, 435, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 435, __pyx_L1_error) /* … */ __Pyx_TraceLine(435,0,__PYX_ERR(0, 435, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fancy_printer, 0, __pyx_n_s_fancy_printer, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__358); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fancy_printer, __pyx_t_2) < 0) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__358 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_u_Data_Quality_Check_Report)); if (unlikely(!__pyx_tuple__358)) __PYX_ERR(0, 435, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__358); __Pyx_GIVEREF(__pyx_tuple__358);
0436: """
0437: This _fancy_print function within the check_data_quality function
0438: iterates over the results dictionary and prints each category
0439: (like missing data, outliers, etc.) in a formatted manner. It only
0440: displays categories with findings, making the output more concise and
0441: focused on the areas that need attention. The use of .title()
0442: and .replace('_', ' ') methods enhances the readability of the
0443: category names.
0444:
0445: Parameters
0446: -----------
0447: result: dict,
0448: the result to print. Must contain a dictionnary.
0449: report_name: str,
0450: A report to fancy printer.
0451:
0452: """
+0453: if not isinstance ( result, dict):
__Pyx_TraceLine(453,0,__PYX_ERR(0, 453, __pyx_L1_error)) __pyx_t_1 = PyDict_Check(__pyx_v_result); __pyx_t_2 = (!__pyx_t_1); if (unlikely(__pyx_t_2)) { /* … */ }
+0454: raise TypeError("fancy_printer accepts only a dictionnary type."
__Pyx_TraceLine(454,0,__PYX_ERR(0, 454, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_fancy_printer_accepts_only_a_dic, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 454, __pyx_L1_error)
+0455: f" Got {type(result).__name__!r}")
__Pyx_TraceLine(455,0,__PYX_ERR(0, 455, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_result)), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_3), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0456:
+0457: print(f"\n{report_name}:\n")
__Pyx_TraceLine(457,0,__PYX_ERR(0, 457, __pyx_L1_error)) __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u__11); __pyx_t_5 += 1; __Pyx_GIVEREF(__pyx_kp_u__11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u__11); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_report_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_6; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__12); __pyx_t_5 += 2; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u__12); __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_4, 3, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0458:
+0459: for key, value in result.items():
__Pyx_TraceLine(459,0,__PYX_ERR(0, 459, __pyx_L1_error)) __pyx_t_5 = 0; if (unlikely(__pyx_v_result == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 459, __pyx_L1_error) } __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_result, 0, __pyx_n_s_items, (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = __pyx_t_3; __pyx_t_3 = 0; while (1) { __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_7, &__pyx_t_5, &__pyx_t_3, &__pyx_t_9, NULL, __pyx_t_8); if (unlikely(__pyx_t_10 == 0)) break; if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_9); __pyx_t_9 = 0;
+0460: if value: # Only display categories with findings
__Pyx_TraceLine(460,0,__PYX_ERR(0, 460, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 460, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L6; }
+0461: print(f"--- {key.replace('_', ' ').title()} ---")
__Pyx_TraceLine(461,0,__PYX_ERR(0, 461, __pyx_L1_error)) __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_11 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u__13); __pyx_t_11 += 4; __Pyx_GIVEREF(__pyx_kp_u__13); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u__13); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_replace); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_title); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_10, 0+__pyx_t_10); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_6; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__16); __pyx_t_11 += 4; __Pyx_GIVEREF(__pyx_kp_u__16); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__16); __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_9, 3, __pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_tuple__15 = PyTuple_Pack(2, __pyx_n_u__8, __pyx_kp_u__14); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 461, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__15); __Pyx_GIVEREF(__pyx_tuple__15);
+0462: print("Column | Details")
__Pyx_TraceLine(462,0,__PYX_ERR(0, 462, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_u_Column_Details); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__17); __Pyx_GIVEREF(__pyx_tuple__17);
+0463: print("-" * 40) # Table header separator
__Pyx_TraceLine(463,0,__PYX_ERR(0, 463, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_tuple__19 = PyTuple_Pack(1, __pyx_kp_u__18); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 463, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__19); __Pyx_GIVEREF(__pyx_tuple__19);
0464:
+0465: try :
__Pyx_TraceLine(465,0,__PYX_ERR(0, 465, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L14_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_L14_try_end:; }
0466:
+0467: for sub_key, sub_value in value.items():
__Pyx_TraceLine(467,0,__PYX_ERR(0, 467, __pyx_L7_error)) __pyx_t_11 = 0; if (unlikely(__pyx_v_value == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 467, __pyx_L7_error) } __pyx_t_12 = __Pyx_dict_iterator(__pyx_v_value, 0, __pyx_n_s_items, (&__pyx_t_17), (&__pyx_t_10)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 467, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = __pyx_t_12; __pyx_t_12 = 0; while (1) { __pyx_t_18 = __Pyx_dict_iter_next(__pyx_t_9, __pyx_t_17, &__pyx_t_11, &__pyx_t_12, &__pyx_t_3, NULL, __pyx_t_10); if (unlikely(__pyx_t_18 == 0)) break; if (unlikely(__pyx_t_18 == -1)) __PYX_ERR(0, 467, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_sub_key, __pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF_SET(__pyx_v_sub_value, __pyx_t_3); __pyx_t_3 = 0;
0468: # Ensuring column name and details fit into the table format
+0469: formatted_key = (sub_key[:15] + '..') if len(
__Pyx_TraceLine(469,0,__PYX_ERR(0, 469, __pyx_L7_error)) __pyx_t_19 = PyObject_Length(__pyx_v_sub_key); if (unlikely(__pyx_t_19 == ((Py_ssize_t)-1))) __PYX_ERR(0, 469, __pyx_L7_error) /* … */ __Pyx_TraceLine(469,0,__PYX_ERR(0, 469, __pyx_L7_error)) __pyx_t_12 = __Pyx_PyObject_GetSlice(__pyx_v_sub_key, 0, 15, NULL, NULL, &__pyx_slice__20, 0, 1, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 469, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyNumber_Add(__pyx_t_12, __pyx_kp_u__21); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 469, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_3 = __pyx_t_13; __pyx_t_13 = 0; } else { /* … */ __pyx_slice__20 = PySlice_New(Py_None, __pyx_int_15, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__20); __Pyx_GIVEREF(__pyx_slice__20);
+0470: sub_key) > 17 else sub_key
__Pyx_TraceLine(470,0,__PYX_ERR(0, 470, __pyx_L7_error)) __pyx_t_2 = (__pyx_t_19 > 17); if (__pyx_t_2) { /* … */ __Pyx_TraceLine(470,0,__PYX_ERR(0, 470, __pyx_L7_error)) __Pyx_INCREF(__pyx_v_sub_key); __pyx_t_3 = __pyx_v_sub_key; } __Pyx_XDECREF_SET(__pyx_v_formatted_key, __pyx_t_3); __pyx_t_3 = 0;
+0471: formatted_value = str(sub_value)[:20] + (
__Pyx_TraceLine(471,0,__PYX_ERR(0, 471, __pyx_L7_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_sub_value); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = PySequence_GetSlice(__pyx_t_3, 0, 20); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 471, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(471,0,__PYX_ERR(0, 471, __pyx_L7_error)) __pyx_t_12 = __Pyx_PyUnicode_ConcatInPlaceSafe(__pyx_t_13, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 471, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_formatted_value, __pyx_t_12); __pyx_t_12 = 0;
+0472: '..' if len(str(sub_value)) > 22 else '')
__Pyx_TraceLine(472,0,__PYX_ERR(0, 472, __pyx_L7_error)) __pyx_t_12 = __Pyx_PyObject_Str(__pyx_v_sub_value); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 472, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_19 = PyObject_Length(__pyx_t_12); if (unlikely(__pyx_t_19 == ((Py_ssize_t)-1))) __PYX_ERR(0, 472, __pyx_L7_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_2 = (__pyx_t_19 > 22); if (__pyx_t_2) { __Pyx_INCREF(__pyx_kp_u__21); __pyx_t_3 = __pyx_kp_u__21; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_3 = __pyx_kp_u__22; }
+0473: print(f"{formatted_key:<17} | {formatted_value}")
__Pyx_TraceLine(473,0,__PYX_ERR(0, 473, __pyx_L7_error)) __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 473, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_19 = 0; __pyx_t_6 = 127; __pyx_t_3 = __Pyx_PyObject_Format(__pyx_v_formatted_key, __pyx_kp_u_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_6; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__23); __pyx_t_19 += 3; __Pyx_GIVEREF(__pyx_kp_u__23); PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_kp_u__23); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_formatted_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_6; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_12, 3, __pyx_t_19, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 473, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+0474: except :
__Pyx_TraceLine(474,0,__PYX_ERR(0, 474, __pyx_L9_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.fancy_printer", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_12, &__pyx_t_3) < 0) __PYX_ERR(0, 474, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_3);
+0475: formatted_key = (key[:15] + '..') if len(key) > 17 else key
__Pyx_TraceLine(475,0,__PYX_ERR(0, 475, __pyx_L9_except_error)) __pyx_t_17 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 475, __pyx_L9_except_error) __pyx_t_2 = (__pyx_t_17 > 17); if (__pyx_t_2) { __pyx_t_20 = __Pyx_PyObject_GetSlice(__pyx_v_key, 0, 15, NULL, NULL, &__pyx_slice__20, 0, 1, 1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 475, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_21 = PyNumber_Add(__pyx_t_20, __pyx_kp_u__21); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 475, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_13 = __pyx_t_21; __pyx_t_21 = 0; } else { __Pyx_INCREF(__pyx_v_key); __pyx_t_13 = __pyx_v_key; } __Pyx_XDECREF_SET(__pyx_v_formatted_key, __pyx_t_13); __pyx_t_13 = 0;
+0476: formatted_value = f"{value:.2f}"
__Pyx_TraceLine(476,0,__PYX_ERR(0, 476, __pyx_L9_except_error)) __pyx_t_13 = __Pyx_PyObject_Format(__pyx_v_value, __pyx_kp_u_2f); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 476, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_XDECREF_SET(__pyx_v_formatted_value, __pyx_t_13); __pyx_t_13 = 0;
+0477: print(f"{formatted_key:<17} | {formatted_value}")
__Pyx_TraceLine(477,0,__PYX_ERR(0, 477, __pyx_L9_except_error)) __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 477, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_17 = 0; __pyx_t_6 = 127; __pyx_t_21 = __Pyx_PyObject_Format(__pyx_v_formatted_key, __pyx_kp_u_17); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 477, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_6; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u__23); __pyx_t_17 += 3; __Pyx_GIVEREF(__pyx_kp_u__23); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_kp_u__23); __pyx_t_21 = __Pyx_PyObject_FormatSimple(__pyx_v_formatted_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 477, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_6; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = __Pyx_PyUnicode_Join(__pyx_t_13, 3, __pyx_t_17, __pyx_t_6); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 477, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_21); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 477, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_exception_handled; }
0478:
+0479: print("\n")
__Pyx_TraceLine(479,0,__PYX_ERR(0, 479, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_u__11); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 479, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24);
0480: else:
+0481: print(f"--- No {key.replace('_', ' ').title()} Found ---\n")
__Pyx_TraceLine(481,0,__PYX_ERR(0, 481, __pyx_L1_error)) /*else*/ { __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u_No); __pyx_t_17 += 7; __Pyx_GIVEREF(__pyx_kp_u_No); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_No); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_key, __pyx_n_s_replace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__15, NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_title); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_10, 0+__pyx_t_10); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_6; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_Found); __pyx_t_17 += 11; __Pyx_GIVEREF(__pyx_kp_u_Found); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_Found); __pyx_t_9 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_17, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 481, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L6:; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
0482:
+0483: def to_numeric_dtypes(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_306__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 483, 0, __PYX_ERR(0, 483, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
/* … */
__Pyx_TraceLine(483,0,__PYX_ERR(0, 483, __pyx_L1_error))
__pyx_t_2 = PyFloat_FromDouble(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_missing_values); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_missing_values, __pyx_t_2) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* … */
__Pyx_TraceLine(483,0,__PYX_ERR(0, 483, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None)) __PYX_ERR(0, 483, __pyx_L1_error);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1)) __PYX_ERR(0, 483, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13to_numeric_dtypes(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_12to_numeric_dtypes, "\n Converts an array to a DataFrame and coerces values to appropriate \n data types.\n\n This function is designed to process data arrays or DataFrames, ensuring\n numeric and categorical features are correctly identified and formatted. \n It provides options to manipulate the data, including column sanitization, \n handling of missing values, and dropping NaN-filled columns.\n\n Parameters\n ----------\n arr : NDArray or DataFrame\n The data to be processed, either as an array or a DataFrame.\n \n columns : list of str, optional\n Column names for creating a DataFrame from an array. \n Length should match the number of columns in `arr`.\n \n return_feature_types : bool, default=False\n If True, returns a tuple with the DataFrame, numeric, and categorical \n features.\n \n missing_values : float, default=np.nan\n Value used to replace missing or empty strings in the DataFrame.\n \n pop_cat_features : bool, default=False\n If True, removes categorical features from the DataFrame.\n \n sanitize_columns : bool, default=False\n If True, cleans the DataFrame columns using the specified `regex` \n pattern.\n \n regex : re.Pattern or str, optional\n Regular expression pattern for column sanitization. the default is:: \n \n >>> import re \n >>> re.compile (r'[_#&.)(*@!_,;\\s-]\\s*', flags=re.IGNORECASE)\n \n fill_pattern : str, default='_'\n String pattern used to replace non-alphanumeric characters in \n column names.\n \n drop_nan_columns : bool, default=True\n If True, drops columns filled entirely with NaN values.\n \n how : str, default='all'\n Determines row dropping strategy based on NaN values.\n \n reset_index : bool, default=False\n If True, resets the index of the DataFrame after processing.\n \n drop_index : bool, default=True\n If True, dr""ops the original index when resetting the DataFrame index.\n \n verbose : bool, default=False\n If True, prints additional information during processing.\n\n Returns\n -------\n DataFrame or tuple of DataFrame, List[str], List[str]\n The processed DataFrame. If `return_feature_types` is True, returns a \n tuple with the DataFrame, list of numeric feature names (`nf`), \n and list of categorical feature names (`cf`).\n\n Examples\n --------\n >>> from gofast.datasets.dload import load_bagoue\n >>> from gofast.tools.coreutils import to_numeric_dtypes\n >>> X= load_bagoue(as_frame=True)\n >>> X0 = X[['shape', 'power', 'magnitude']]\n >>> df, nf, cf = to_numeric_dtypes(X0, return_feature_types=True)\n >>> print(df.dtypes, nf, cf)\n >>> X0.dtypes \n ... shape object\n power object\n magnitude object\n dtype: object\n >>> df = to_numeric_dtypes(X0)\n >>> df.dtypes \n ... shape object\n power float64\n magnitude float64\n dtype: object\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_13to_numeric_dtypes = {"to_numeric_dtypes", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_13to_numeric_dtypes, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_12to_numeric_dtypes};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13to_numeric_dtypes(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_arr = 0;
PyObject *__pyx_v_columns = 0;
PyObject *__pyx_v_return_feature_types = 0;
double __pyx_v_missing_values;
PyObject *__pyx_v_pop_cat_features = 0;
PyObject *__pyx_v_sanitize_columns = 0;
PyObject *__pyx_v_regex = 0;
PyObject *__pyx_v_fill_pattern = 0;
PyObject *__pyx_v_drop_nan_columns = 0;
PyObject *__pyx_v_how = 0;
PyObject *__pyx_v_reset_index = 0;
PyObject *__pyx_v_drop_index = 0;
PyObject *__pyx_v_verbose = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("to_numeric_dtypes (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_columns,&__pyx_n_s_return_feature_types,&__pyx_n_s_missing_values,&__pyx_n_s_pop_cat_features,&__pyx_n_s_sanitize_columns,&__pyx_n_s_regex,&__pyx_n_s_fill_pattern,&__pyx_n_s_drop_nan_columns,&__pyx_n_s_how,&__pyx_n_s_reset_index,&__pyx_n_s_drop_index,&__pyx_n_s_verbose,0};
PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
__pyx_defaults *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_12to_numeric_dtypes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_columns, PyObject *__pyx_v_return_feature_types, double __pyx_v_missing_values, PyObject *__pyx_v_pop_cat_features, PyObject *__pyx_v_sanitize_columns, PyObject *__pyx_v_regex, PyObject *__pyx_v_fill_pattern, PyObject *__pyx_v_drop_nan_columns, PyObject *__pyx_v_how, PyObject *__pyx_v_reset_index, PyObject *__pyx_v_drop_index, PyObject *__pyx_v_verbose) {
PyObject *__pyx_v__is_numeric_dtype = NULL;
PyObject *__pyx_v_df = NULL;
PyObject *__pyx_v_serie = NULL;
PyObject *__pyx_v_nan_columns = NULL;
PyObject *__pyx_v_nf = NULL;
PyObject *__pyx_v_cf = NULL;
PyObject *__pyx_v_msg = NULL;
PyObject *__pyx_v_b = NULL;
PyObject *__pyx_v_e = NULL;
PyObject *__pyx_8genexpr6__pyx_v_item = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__25)
__Pyx_TraceCall("to_numeric_dtypes", __pyx_f[0], 483, 0, __PYX_ERR(0, 483, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_return_feature_types);
__Pyx_INCREF(__pyx_v_pop_cat_features);
__Pyx_INCREF(__pyx_v_sanitize_columns);
__Pyx_INCREF(__pyx_v_reset_index);
__Pyx_INCREF(__pyx_v_verbose);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_AddTraceback("gofast.tools.coreutils.to_numeric_dtypes", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v__is_numeric_dtype);
__Pyx_XDECREF(__pyx_v_df);
__Pyx_XDECREF(__pyx_v_serie);
__Pyx_XDECREF(__pyx_v_nan_columns);
__Pyx_XDECREF(__pyx_v_nf);
__Pyx_XDECREF(__pyx_v_cf);
__Pyx_XDECREF(__pyx_v_msg);
__Pyx_XDECREF(__pyx_v_b);
__Pyx_XDECREF(__pyx_v_e);
__Pyx_XDECREF(__pyx_8genexpr6__pyx_v_item);
__Pyx_XDECREF(__pyx_v_return_feature_types);
__Pyx_XDECREF(__pyx_v_pop_cat_features);
__Pyx_XDECREF(__pyx_v_sanitize_columns);
__Pyx_XDECREF(__pyx_v_reset_index);
__Pyx_XDECREF(__pyx_v_verbose);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__359 = PyTuple_Pack(23, __pyx_n_s_arr, __pyx_n_s_columns, __pyx_n_s_return_feature_types, __pyx_n_s_missing_values, __pyx_n_s_pop_cat_features, __pyx_n_s_sanitize_columns, __pyx_n_s_regex, __pyx_n_s_fill_pattern, __pyx_n_s_drop_nan_columns, __pyx_n_s_how, __pyx_n_s_reset_index, __pyx_n_s_drop_index, __pyx_n_s_verbose, __pyx_n_s_is_numeric_dtype, __pyx_n_s_df, __pyx_n_s_serie, __pyx_n_s_nan_columns, __pyx_n_s_nf, __pyx_n_s_cf, __pyx_n_s_msg, __pyx_n_s_b, __pyx_n_s_e, __pyx_n_s_item); if (unlikely(!__pyx_tuple__359)) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__359);
__Pyx_GIVEREF(__pyx_tuple__359);
/* … */
__Pyx_TraceLine(483,0,__PYX_ERR(0, 483, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_arr, __pyx_kp_s_Union_NDArray_DataFrame) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_kp_s_Optional_List_str) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return_feature_types, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_missing_values, __pyx_n_s_float) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_pop_cat_features, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_sanitize_columns, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_regex, __pyx_kp_s_Optional_re_Pattern) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_fill_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_drop_nan_columns, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_how, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_reset_index, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_drop_index, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_verbose, __pyx_n_s_bool) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Union_DataFrame_Tuple_DataFrame) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_13to_numeric_dtypes, 0, __pyx_n_s_to_numeric_dtypes, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__25)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 483, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults), 0)) __PYX_ERR(0, 483, __pyx_L1_error)
__pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(1, 0, 12, 23, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__359, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_to_numeric_dtypes, 483, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) __PYX_ERR(0, 483, __pyx_L1_error)
0484: arr: Union[NDArray, DataFrame], *,
+0485: columns: Optional[List[str]] = None,
__Pyx_TraceLine(485,0,__PYX_ERR(0, 485, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_columns, Py_None) < 0) __PYX_ERR(0, 483, __pyx_L1_error) /* … */ values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis)));
+0486: return_feature_types: bool = ...,
__Pyx_TraceLine(486,0,__PYX_ERR(0, 486, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_return_feature_types, ((PyObject *)Py_Ellipsis)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
+0487: missing_values: float = np.nan,
__Pyx_TraceLine(487,0,__PYX_ERR(0, 487, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 487, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_4)->__pyx_arg_missing_values = __pyx_t_6; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_6gofast_5tools_9coreutils_306__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_numeric_dtypes, __pyx_t_4) < 0) __PYX_ERR(0, 483, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0488: pop_cat_features: bool = ...,
__Pyx_TraceLine(488,0,__PYX_ERR(0, 488, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pop_cat_features, ((PyObject *)Py_Ellipsis)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
+0489: sanitize_columns: bool = ...,
__Pyx_TraceLine(489,0,__PYX_ERR(0, 489, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sanitize_columns, ((PyObject *)Py_Ellipsis)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
+0490: regex: Optional[re.Pattern] = None,
__Pyx_TraceLine(490,0,__PYX_ERR(0, 490, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_regex, Py_None) < 0) __PYX_ERR(0, 483, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_fill_pattern, ((PyObject*)__pyx_n_u__8)) < 0) __PYX_ERR(0, 483, __pyx_L1_error) /* … */ values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u__8))); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_all))); values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); values[11] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[12] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args > 0 && likely(kw_args <= 12)) { Py_ssize_t index; for (index = 1; index < 13 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 483, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "to_numeric_dtypes") < 0)) __PYX_ERR(0, 483, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_arr = values[0]; __pyx_v_columns = values[1]; __pyx_v_return_feature_types = values[2]; if (values[3]) { __pyx_v_missing_values = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_missing_values == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 487, __pyx_L3_error) } else { __pyx_v_missing_values = __pyx_dynamic_args->__pyx_arg_missing_values; } __pyx_v_pop_cat_features = values[4]; __pyx_v_sanitize_columns = values[5]; __pyx_v_regex = values[6]; __pyx_v_fill_pattern = ((PyObject*)values[7]); __pyx_v_drop_nan_columns = values[8]; __pyx_v_how = ((PyObject*)values[9]); __pyx_v_reset_index = values[10]; __pyx_v_drop_index = values[11]; __pyx_v_verbose = values[12]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_numeric_dtypes", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 483, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.to_numeric_dtypes", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fill_pattern), (&PyUnicode_Type), 0, "fill_pattern", 1))) __PYX_ERR(0, 491, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_how), (&PyUnicode_Type), 0, "how", 1))) __PYX_ERR(0, 493, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_12to_numeric_dtypes(__pyx_self, __pyx_v_arr, __pyx_v_columns, __pyx_v_return_feature_types, __pyx_v_missing_values, __pyx_v_pop_cat_features, __pyx_v_sanitize_columns, __pyx_v_regex, __pyx_v_fill_pattern, __pyx_v_drop_nan_columns, __pyx_v_how, __pyx_v_reset_index, __pyx_v_drop_index, __pyx_v_verbose);
0491: fill_pattern: str = '_',
+0492: drop_nan_columns: bool = True,
__Pyx_TraceLine(492,0,__PYX_ERR(0, 492, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_drop_nan_columns, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 483, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_how, ((PyObject*)__pyx_n_u_all)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
0493: how: str = 'all',
+0494: reset_index: bool = ...,
__Pyx_TraceLine(494,0,__PYX_ERR(0, 494, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_reset_index, ((PyObject *)Py_Ellipsis)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
+0495: drop_index: bool = True,
__Pyx_TraceLine(495,0,__PYX_ERR(0, 495, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_drop_index, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
+0496: verbose: bool = ...
__Pyx_TraceLine(496,0,__PYX_ERR(0, 496, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_verbose, ((PyObject *)Py_Ellipsis)) < 0) __PYX_ERR(0, 483, __pyx_L1_error)
0497: ) -> Union[DataFrame, Tuple[DataFrame, List[str], List[str]]]:
0498: """
0499: Converts an array to a DataFrame and coerces values to appropriate
0500: data types.
0501:
0502: This function is designed to process data arrays or DataFrames, ensuring
0503: numeric and categorical features are correctly identified and formatted.
0504: It provides options to manipulate the data, including column sanitization,
0505: handling of missing values, and dropping NaN-filled columns.
0506:
0507: Parameters
0508: ----------
0509: arr : NDArray or DataFrame
0510: The data to be processed, either as an array or a DataFrame.
0511:
0512: columns : list of str, optional
0513: Column names for creating a DataFrame from an array.
0514: Length should match the number of columns in `arr`.
0515:
0516: return_feature_types : bool, default=False
0517: If True, returns a tuple with the DataFrame, numeric, and categorical
0518: features.
0519:
0520: missing_values : float, default=np.nan
0521: Value used to replace missing or empty strings in the DataFrame.
0522:
0523: pop_cat_features : bool, default=False
0524: If True, removes categorical features from the DataFrame.
0525:
0526: sanitize_columns : bool, default=False
0527: If True, cleans the DataFrame columns using the specified `regex`
0528: pattern.
0529:
0530: regex : re.Pattern or str, optional
0531: Regular expression pattern for column sanitization. the default is::
0532:
0533: >>> import re
0534: >>> re.compile (r'[_#&.)(*@!_,;\s-]\s*', flags=re.IGNORECASE)
0535:
0536: fill_pattern : str, default='_'
0537: String pattern used to replace non-alphanumeric characters in
0538: column names.
0539:
0540: drop_nan_columns : bool, default=True
0541: If True, drops columns filled entirely with NaN values.
0542:
0543: how : str, default='all'
0544: Determines row dropping strategy based on NaN values.
0545:
0546: reset_index : bool, default=False
0547: If True, resets the index of the DataFrame after processing.
0548:
0549: drop_index : bool, default=True
0550: If True, drops the original index when resetting the DataFrame index.
0551:
0552: verbose : bool, default=False
0553: If True, prints additional information during processing.
0554:
0555: Returns
0556: -------
0557: DataFrame or tuple of DataFrame, List[str], List[str]
0558: The processed DataFrame. If `return_feature_types` is True, returns a
0559: tuple with the DataFrame, list of numeric feature names (`nf`),
0560: and list of categorical feature names (`cf`).
0561:
0562: Examples
0563: --------
0564: >>> from gofast.datasets.dload import load_bagoue
0565: >>> from gofast.tools.coreutils import to_numeric_dtypes
0566: >>> X= load_bagoue(as_frame=True)
0567: >>> X0 = X[['shape', 'power', 'magnitude']]
0568: >>> df, nf, cf = to_numeric_dtypes(X0, return_feature_types=True)
0569: >>> print(df.dtypes, nf, cf)
0570: >>> X0.dtypes
0571: ... shape object
0572: power object
0573: magnitude object
0574: dtype: object
0575: >>> df = to_numeric_dtypes(X0)
0576: >>> df.dtypes
0577: ... shape object
0578: power float64
0579: magnitude float64
0580: dtype: object
0581: """
0582:
+0583: from .validator import _is_numeric_dtype
__Pyx_TraceLine(583,0,__PYX_ERR(0, 583, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_is_numeric_dtype); __Pyx_GIVEREF(__pyx_n_s_is_numeric_dtype); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_is_numeric_dtype)) __PYX_ERR(0, 583, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_validator, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_is_numeric_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v__is_numeric_dtype = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0584: # pass ellipsis argument to False
+0585: ( sanitize_columns, reset_index,
__Pyx_TraceLine(585,0,__PYX_ERR(0, 585, __pyx_L1_error)) __Pyx_DECREF_SET(__pyx_v_sanitize_columns, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_reset_index, __pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_verbose, __pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_return_feature_types, __pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_pop_cat_features, __pyx_t_7); __pyx_t_7 = 0;
0586: verbose,return_feature_types,
0587: pop_cat_features,
+0588: ) = ellipsis2false(
__Pyx_TraceLine(588,0,__PYX_ERR(0, 588, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ellipsis2false); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
0589: sanitize_columns,
0590: reset_index,
0591: verbose,
0592: return_feature_types,
+0593: pop_cat_features
__Pyx_TraceLine(593,0,__PYX_ERR(0, 593, __pyx_L1_error)) __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_v_sanitize_columns, __pyx_v_reset_index, __pyx_v_verbose, __pyx_v_return_feature_types, __pyx_v_pop_cat_features}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 5+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 5)) { if (size > 5) __Pyx_RaiseTooManyValuesError(5); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 585, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 4); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); __pyx_t_5 = PyList_GET_ITEM(sequence, 2); __pyx_t_6 = PyList_GET_ITEM(sequence, 3); __pyx_t_7 = PyList_GET_ITEM(sequence, 4); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else { Py_ssize_t i; PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_3,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7}; for (i=0; i < 5; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 585, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; PyObject** temps[5] = {&__pyx_t_1,&__pyx_t_3,&__pyx_t_5,&__pyx_t_6,&__pyx_t_7}; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 585, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); for (index=0; index < 5; index++) { PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 5) < 0) __PYX_ERR(0, 585, __pyx_L1_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 585, __pyx_L1_error) __pyx_L4_unpacking_done:; }
0594: )
0595:
+0596: if not is_iterable (arr, exclude_string=True):
__Pyx_TraceLine(596,0,__PYX_ERR(0, 596, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_arr); __Pyx_GIVEREF(__pyx_v_arr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_arr)) __PYX_ERR(0, 596, __pyx_L1_error); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 596, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = (!__pyx_t_10); if (unlikely(__pyx_t_11)) { /* … */ }
+0597: raise TypeError(f"Expect array. Got {type (arr).__name__!r}")
__Pyx_TraceLine(597,0,__PYX_ERR(0, 597, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_arr)), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_array_Got, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 597, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 597, __pyx_L1_error)
0598:
+0599: if hasattr ( arr, '__array__') and hasattr ( arr, 'columns'):
__Pyx_TraceLine(599,0,__PYX_ERR(0, 599, __pyx_L1_error)) __pyx_t_10 = __Pyx_HasAttr(__pyx_v_arr, __pyx_n_u_array_2); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 599, __pyx_L1_error) if (__pyx_t_10) { } else { __pyx_t_11 = __pyx_t_10; goto __pyx_L7_bool_binop_done; } __pyx_t_10 = __Pyx_HasAttr(__pyx_v_arr, __pyx_n_u_columns); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 599, __pyx_L1_error) __pyx_t_11 = __pyx_t_10; __pyx_L7_bool_binop_done:; if (__pyx_t_11) { /* … */ goto __pyx_L6; }
+0600: df = arr.copy()
__Pyx_TraceLine(600,0,__PYX_ERR(0, 600, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_df = __pyx_t_6; __pyx_t_6 = 0;
+0601: if columns is not None:
__Pyx_TraceLine(601,0,__PYX_ERR(0, 601, __pyx_L1_error)) __pyx_t_11 = (__pyx_v_columns != Py_None); if (__pyx_t_11) { /* … */ }
+0602: if verbose:
__Pyx_TraceLine(602,0,__PYX_ERR(0, 602, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 602, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
+0603: print("Dataframe is passed. Columns should be replaced.")
__Pyx_TraceLine(603,0,__PYX_ERR(0, 603, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__27, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_u_Dataframe_is_passed_Columns_shou); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 603, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__27); __Pyx_GIVEREF(__pyx_tuple__27);
+0604: df =pd.DataFrame ( np.array ( arr), columns =columns )
__Pyx_TraceLine(604,0,__PYX_ERR(0, 604, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_arr}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_columns, __pyx_v_columns) < 0) __PYX_ERR(0, 604, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_df, __pyx_t_7); __pyx_t_7 = 0;
0605:
+0606: else: df = pd.DataFrame (arr, columns =columns )
__Pyx_TraceLine(606,0,__PYX_ERR(0, 606, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_arr); __Pyx_GIVEREF(__pyx_v_arr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_arr)) __PYX_ERR(0, 606, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_v_columns) < 0) __PYX_ERR(0, 606, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_df = __pyx_t_5; __pyx_t_5 = 0; } __pyx_L6:;
0607:
0608: # sanitize columns
+0609: if sanitize_columns:
__Pyx_TraceLine(609,0,__PYX_ERR(0, 609, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_sanitize_columns); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 609, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
0610: # Pass in the case columns are all integer values.
+0611: if not _is_numeric_dtype(df.columns , to_array=True):
__Pyx_TraceLine(611,0,__PYX_ERR(0, 611, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_to_array, Py_True) < 0) __PYX_ERR(0, 611, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_v__is_numeric_dtype, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 611, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_10 = (!__pyx_t_11); if (__pyx_t_10) { /* … */ }
0612: # for consistency reconvert to str
+0613: df.columns = df.columns.astype(str)
__Pyx_TraceLine(613,0,__PYX_ERR(0, 613, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, ((PyObject *)(&PyUnicode_Type))}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (__Pyx_PyObject_SetAttrStr(__pyx_v_df, __pyx_n_s_columns, __pyx_t_7) < 0) __PYX_ERR(0, 613, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+0614: df = sanitize_frame_cols(
__Pyx_TraceLine(614,0,__PYX_ERR(0, 614, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_sanitize_frame_cols); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); /* … */ __Pyx_TraceLine(615,0,__PYX_ERR(0, 615, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_df); __Pyx_GIVEREF(__pyx_v_df); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_df)) __PYX_ERR(0, 614, __pyx_L1_error); /* … */ __Pyx_TraceLine(614,0,__PYX_ERR(0, 614, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_df, __pyx_t_6); __pyx_t_6 = 0;
+0615: df, regex=regex, fill_pattern=fill_pattern )
__pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_regex, __pyx_v_regex) < 0) __PYX_ERR(0, 615, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_fill_pattern, __pyx_v_fill_pattern) < 0) __PYX_ERR(0, 615, __pyx_L1_error)
0616:
0617: #replace empty string by Nan if NaN exist in dataframe
+0618: df= df.replace(r'^\s*$', missing_values, regex=True)
__Pyx_TraceLine(618,0,__PYX_ERR(0, 618, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_replace); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyFloat_FromDouble(__pyx_v_missing_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_kp_u_s); __Pyx_GIVEREF(__pyx_kp_u_s); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_s)) __PYX_ERR(0, 618, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5)) __PYX_ERR(0, 618, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_regex, Py_True) < 0) __PYX_ERR(0, 618, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_df, __pyx_t_7); __pyx_t_7 = 0;
0619:
0620: # check the possibililty to cast all
0621: # the numerical data
+0622: for serie in df.columns:
__Pyx_TraceLine(622,0,__PYX_ERR(0, 622, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_5 = __pyx_t_7; __Pyx_INCREF(__pyx_t_5); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 622, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_5))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 622, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 622, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 622, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_12); __Pyx_INCREF(__pyx_t_7); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 622, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_13(__pyx_t_5); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 622, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v_serie, __pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(622,0,__PYX_ERR(0, 622, __pyx_L1_error)) __pyx_L13_continue:; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+0623: try:
__Pyx_TraceLine(623,0,__PYX_ERR(0, 623, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L22_try_end; __pyx_L15_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L17_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L1_error; __pyx_L21_try_continue:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L13_continue; __pyx_L22_try_end:; }
+0624: df= df.astype(
__Pyx_TraceLine(624,0,__PYX_ERR(0, 624, __pyx_L15_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2);
+0625: {serie:np.float64})
__Pyx_TraceLine(625,0,__PYX_ERR(0, 625, __pyx_L15_error)) __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 625, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 625, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 625, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_v_serie, __pyx_t_1) < 0) __PYX_ERR(0, 625, __pyx_L15_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_6}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 624, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_df, __pyx_t_7); __pyx_t_7 = 0;
+0626: except:continue
__Pyx_TraceLine(626,0,__PYX_ERR(0, 626, __pyx_L17_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.to_numeric_dtypes", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_6) < 0) __PYX_ERR(0, 626, __pyx_L17_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_6); goto __pyx_L23_except_continue; __pyx_L23_except_continue:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L21_try_continue; }
0627:
0628: # drop nan columns if exists
+0629: if drop_nan_columns:
__Pyx_TraceLine(629,0,__PYX_ERR(0, 629, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_drop_nan_columns); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 629, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+0630: if verbose:
__Pyx_TraceLine(630,0,__PYX_ERR(0, 630, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 630, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+0631: nan_columns = df.columns [ df.isna().all()].tolist()
__Pyx_TraceLine(631,0,__PYX_ERR(0, 631, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_isna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_all); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tolist); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_nan_columns = __pyx_t_5; __pyx_t_5 = 0;
+0632: print("No NaN column found.") if len(
__Pyx_TraceLine(632,0,__PYX_ERR(0, 632, __pyx_L1_error)) __pyx_t_12 = PyObject_Length(__pyx_v_nan_columns); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 632, __pyx_L1_error) /* … */ __Pyx_TraceLine(632,0,__PYX_ERR(0, 632, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __pyx_t_2; __pyx_t_2 = 0; } else { /* … */ __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_u_No_NaN_column_found); if (unlikely(!__pyx_tuple__28)) __PYX_ERR(0, 632, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__28); __Pyx_GIVEREF(__pyx_tuple__28);
+0633: nan_columns)==0 else listing_items_format (nan_columns,
__Pyx_TraceLine(633,0,__PYX_ERR(0, 633, __pyx_L1_error)) __pyx_t_10 = (__pyx_t_12 == 0); if (__pyx_t_10) { /* … */ __Pyx_TraceLine(633,0,__PYX_ERR(0, 633, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_listing_items_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_nan_columns); __Pyx_GIVEREF(__pyx_v_nan_columns); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_nan_columns)) __PYX_ERR(0, 633, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_NaN_columns_found_in_the_data); __Pyx_GIVEREF(__pyx_kp_u_NaN_columns_found_in_the_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u_NaN_columns_found_in_the_data)) __PYX_ERR(0, 633, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__14); __Pyx_GIVEREF(__pyx_kp_u__14); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14)) __PYX_ERR(0, 633, __pyx_L1_error); /* … */ __Pyx_TraceLine(633,0,__PYX_ERR(0, 633, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = __pyx_t_7; __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
0634: "NaN columns found in the data",
+0635: " ", inline =True, lstyle='.')
__Pyx_TraceLine(635,0,__PYX_ERR(0, 635, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 635, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_inline, Py_True) < 0) __PYX_ERR(0, 635, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_lstyle, __pyx_kp_u__26) < 0) __PYX_ERR(0, 635, __pyx_L1_error)
0636: # drop rows and columns with NaN values everywhere.
+0637: df.dropna ( axis=1, how='all', inplace =True)
__Pyx_TraceLine(637,0,__PYX_ERR(0, 637, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_dropna); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 637, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_how, __pyx_n_u_all) < 0) __PYX_ERR(0, 637, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 637, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_empty_tuple, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 637, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0638: if str(how).lower()=='all':
__Pyx_TraceLine(638,0,__PYX_ERR(0, 638, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Str(__pyx_v_how); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_n_u_all, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 638, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_10) { /* … */ }
+0639: df.dropna ( axis=0, how='all', inplace =True)
__Pyx_TraceLine(639,0,__PYX_ERR(0, 639, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_dropna); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 639, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_how, __pyx_n_u_all) < 0) __PYX_ERR(0, 639, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 639, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0640:
0641: # reset_index of the dataframe
0642: # This is useful after droping rows
+0643: if reset_index:
__Pyx_TraceLine(643,0,__PYX_ERR(0, 643, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_reset_index); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 643, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+0644: df.reset_index (inplace =True, drop = drop_index )
__Pyx_TraceLine(644,0,__PYX_ERR(0, 644, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_reset_index); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 644, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_drop, __pyx_v_drop_index) < 0) __PYX_ERR(0, 644, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0645: # collect numeric and non-numeric data
+0646: nf, cf =[], []
__Pyx_TraceLine(646,0,__PYX_ERR(0, 646, __pyx_L1_error)) __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 646, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_v_nf = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; __pyx_v_cf = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+0647: for serie in df.columns:
__Pyx_TraceLine(647,0,__PYX_ERR(0, 647, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 647, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_6))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 647, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 647, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 647, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 647, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_13(__pyx_t_6); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 647, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_serie, __pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(647,0,__PYX_ERR(0, 647, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0648: if _is_numeric_dtype(df[serie], to_array =True ):
__Pyx_TraceLine(648,0,__PYX_ERR(0, 648, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_df, __pyx_v_serie); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5)) __PYX_ERR(0, 648, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_to_array, Py_True) < 0) __PYX_ERR(0, 648, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v__is_numeric_dtype, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 648, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_10) { /* … */ goto __pyx_L32; }
+0649: nf.append(serie)
__Pyx_TraceLine(649,0,__PYX_ERR(0, 649, __pyx_L1_error)) __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_nf, __pyx_v_serie); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 649, __pyx_L1_error)
+0650: else: cf.append(serie)
__Pyx_TraceLine(650,0,__PYX_ERR(0, 650, __pyx_L1_error)) /*else*/ { __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_cf, __pyx_v_serie); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 650, __pyx_L1_error) } __pyx_L32:;
0651:
+0652: if pop_cat_features:
__Pyx_TraceLine(652,0,__PYX_ERR(0, 652, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_pop_cat_features); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 652, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+0653: [ df.pop(item) for item in cf ]
__Pyx_TraceLine(653,0,__PYX_ERR(0, 653, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 653, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __pyx_v_cf; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 653, __pyx_L37_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_5); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 653, __pyx_L37_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 653, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_8genexpr6__pyx_v_item, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_pop); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 653, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_8genexpr6__pyx_v_item}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 653, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 653, __pyx_L37_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_item); __pyx_8genexpr6__pyx_v_item = 0; goto __pyx_L41_exit_scope; __pyx_L37_error:; __Pyx_XDECREF(__pyx_8genexpr6__pyx_v_item); __pyx_8genexpr6__pyx_v_item = 0; goto __pyx_L1_error; __pyx_L41_exit_scope:; } /* exit inner scope */ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0654: if verbose:
__Pyx_TraceLine(654,0,__PYX_ERR(0, 654, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 654, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+0655: msg ="Dataframe does not contain any categorial features."
__Pyx_TraceLine(655,0,__PYX_ERR(0, 655, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_Dataframe_does_not_contain_any_c); __pyx_v_msg = __pyx_kp_u_Dataframe_does_not_contain_any_c;
+0656: b= f"Feature{'s' if len(cf)>1 else ''}"
__Pyx_TraceLine(656,0,__PYX_ERR(0, 656, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyList_GET_SIZE(__pyx_v_cf); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 656, __pyx_L1_error) __pyx_t_10 = (__pyx_t_12 > 1); if (__pyx_t_10) { __Pyx_INCREF(__pyx_n_u_s_2); __pyx_t_6 = __pyx_n_u_s_2; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_6 = __pyx_kp_u__22; } __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_n_u_Feature, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_b = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0;
+0657: e = (f"{'have' if len(cf) >1 else 'has'} been dropped"
__Pyx_TraceLine(657,0,__PYX_ERR(0, 657, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyList_GET_SIZE(__pyx_v_cf); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 657, __pyx_L1_error) __pyx_t_10 = (__pyx_t_12 > 1); if (__pyx_t_10) { __Pyx_INCREF(__pyx_n_u_have); __pyx_t_6 = __pyx_n_u_have; } else { __Pyx_INCREF(__pyx_n_u_has); __pyx_t_6 = __pyx_n_u_has; } __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_1, __pyx_kp_u_been_dropped_from_the_dataframe); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_e = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0;
0658: " from the dataframe.")
+0659: print(msg) if len(cf)==0 else listing_items_format (
__Pyx_TraceLine(659,0,__PYX_ERR(0, 659, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyList_GET_SIZE(__pyx_v_cf); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 659, __pyx_L1_error) __pyx_t_10 = (__pyx_t_12 == 0); if (__pyx_t_10) { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __pyx_t_1; __pyx_t_1 = 0; } else { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_listing_items_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(660,0,__PYX_ERR(0, 660, __pyx_L1_error)) __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_cf); __Pyx_GIVEREF(__pyx_v_cf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_cf)) __PYX_ERR(0, 659, __pyx_L1_error); __Pyx_INCREF(__pyx_v_b); __Pyx_GIVEREF(__pyx_v_b); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_b)) __PYX_ERR(0, 659, __pyx_L1_error); __Pyx_INCREF(__pyx_v_e); __Pyx_GIVEREF(__pyx_v_e); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_e)) __PYX_ERR(0, 659, __pyx_L1_error); /* … */ __Pyx_TraceLine(659,0,__PYX_ERR(0, 659, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0660: cf , b, e ,lstyle ='.', inline=True)
__pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_lstyle, __pyx_kp_u__26) < 0) __PYX_ERR(0, 660, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_inline, Py_True) < 0) __PYX_ERR(0, 660, __pyx_L1_error)
0661:
+0662: return df
__Pyx_TraceLine(662,0,__PYX_ERR(0, 662, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_df); __pyx_r = __pyx_v_df; goto __pyx_L0;
0663:
+0664: return (df, nf, cf) if return_feature_types else df
__Pyx_TraceLine(664,0,__PYX_ERR(0, 664, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_return_feature_types); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 664, __pyx_L1_error) if (__pyx_t_10) { __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_df); __Pyx_GIVEREF(__pyx_v_df); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_df)) __PYX_ERR(0, 664, __pyx_L1_error); __Pyx_INCREF(__pyx_v_nf); __Pyx_GIVEREF(__pyx_v_nf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_nf)) __PYX_ERR(0, 664, __pyx_L1_error); __Pyx_INCREF(__pyx_v_cf); __Pyx_GIVEREF(__pyx_v_cf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_cf)) __PYX_ERR(0, 664, __pyx_L1_error); __pyx_t_6 = __pyx_t_2; __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_v_df); __pyx_t_6 = __pyx_v_df; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
0665:
+0666: def listing_items_format (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_15listing_items_format(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_14listing_items_format, " Format list by enumerate them successively with carriage return\n \n :param lst: list,\n object for listening \n :param begintext: str, \n Text to display at the beginning of listing the items in `lst`. \n :param endtext: str, \n Text to display at the end of the listing items in `lst`. \n :param enum:bool, default=True, \n Count the number of items in `lst` and display it \n :param lstyle: str, default =None \n listing marker. \n :param bullet:str, default='-'\n symbol that is used to introduce item if `enum` is set to False. \n :param space: int, \n number of space to keep before each outputted item in `lst`\n :param inline: bool, default=False, \n Display all element inline rather than carriage return every times. \n :param verbose: bool, \n Always True for print. If set to False, return list of string \n litteral text. \n :returns: None or str \n None or string litteral if verbose is set to ``False``.\n Examples\n ---------\n >>> from gofast.tools.coreutils import listing_items_format \n >>> litems = ['hole_number', 'depth_top', 'depth_bottom', 'strata_name', \n 'rock_name','thickness', 'resistivity', 'gamma_gamma', \n 'natural_gamma', 'sp','short_distance_gamma', 'well_diameter']\n >>> listing_items_format (litems , 'Features' , \n 'have been successfully drop.' , \n lstyle ='.', space=3) \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_15listing_items_format = {"listing_items_format", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_15listing_items_format, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_14listing_items_format}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_15listing_items_format(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_lst = 0; PyObject *__pyx_v_begintext = 0; PyObject *__pyx_v_endtext = 0; PyObject *__pyx_v_bullet = 0; PyObject *__pyx_v_enum = 0; PyObject *__pyx_v_lstyle = 0; PyObject *__pyx_v_space = 0; PyObject *__pyx_v_inline = 0; PyObject *__pyx_v_verbose = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("listing_items_format (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lst,&__pyx_n_s_begintext,&__pyx_n_s_endtext,&__pyx_n_s_bullet,&__pyx_n_s_enum,&__pyx_n_s_lstyle,&__pyx_n_s_space,&__pyx_n_s_inline,&__pyx_n_s_verbose,0}; PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__22))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__22))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__29))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_14listing_items_format(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lst, PyObject *__pyx_v_begintext, PyObject *__pyx_v_endtext, PyObject *__pyx_v_bullet, PyObject *__pyx_v_enum, PyObject *__pyx_v_lstyle, PyObject *__pyx_v_space, PyObject *__pyx_v_inline, PyObject *__pyx_v_verbose) { PyObject *__pyx_v_out = NULL; PyObject *__pyx_v_b = NULL; PyObject *__pyx_v_k = NULL; PyObject *__pyx_v_item = NULL; PyObject *__pyx_v_sp = NULL; PyObject *__pyx_v_o = NULL; PyObject *__pyx_v_en = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__30) __Pyx_TraceCall("listing_items_format", __pyx_f[0], 666, 0, __PYX_ERR(0, 666, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_lst); __Pyx_INCREF(__pyx_v_begintext); __Pyx_INCREF(__pyx_v_endtext); __Pyx_INCREF(__pyx_v_lstyle); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils.listing_items_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_out); __Pyx_XDECREF(__pyx_v_b); __Pyx_XDECREF(__pyx_v_k); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_sp); __Pyx_XDECREF(__pyx_v_o); __Pyx_XDECREF(__pyx_v_en); __Pyx_XDECREF(__pyx_v_lst); __Pyx_XDECREF(__pyx_v_begintext); __Pyx_XDECREF(__pyx_v_endtext); __Pyx_XDECREF(__pyx_v_lstyle); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__360 = PyTuple_Pack(16, __pyx_n_s_lst, __pyx_n_s_begintext, __pyx_n_s_endtext, __pyx_n_s_bullet, __pyx_n_s_enum, __pyx_n_s_lstyle, __pyx_n_s_space, __pyx_n_s_inline, __pyx_n_s_verbose, __pyx_n_s_out, __pyx_n_s_b, __pyx_n_s_k, __pyx_n_s_item, __pyx_n_s_sp, __pyx_n_s_o, __pyx_n_s_en); if (unlikely(!__pyx_tuple__360)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__360); __Pyx_GIVEREF(__pyx_tuple__360); __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(9, 0, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__360, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_listing_items_format, 666, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 666, __pyx_L1_error) /* … */ __Pyx_TraceLine(666,0,__PYX_ERR(0, 666, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_15listing_items_format, 0, __pyx_n_s_listing_items_format, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__30)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__361); if (PyDict_SetItem(__pyx_d, __pyx_n_s_listing_items_format, __pyx_t_4) < 0) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__361 = PyTuple_Pack(8, ((PyObject*)__pyx_kp_u__22), ((PyObject*)__pyx_kp_u__22), ((PyObject*)__pyx_kp_u__29), ((PyObject *)Py_True), Py_None, ((PyObject *)__pyx_int_3), ((PyObject *)Py_False), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__361)) __PYX_ERR(0, 666, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__361); __Pyx_GIVEREF(__pyx_tuple__361);
0667: lst, begintext ='', endtext='' , bullet='-',
+0668: enum =True , lstyle=None , space =3 , inline =False, verbose=True
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_3))); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lst)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_begintext); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_endtext); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_bullet); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_enum); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lstyle); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_space); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_inline); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 666, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "listing_items_format") < 0)) __PYX_ERR(0, 666, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_lst = values[0]; __pyx_v_begintext = values[1]; __pyx_v_endtext = values[2]; __pyx_v_bullet = values[3]; __pyx_v_enum = values[4]; __pyx_v_lstyle = values[5]; __pyx_v_space = values[6]; __pyx_v_inline = values[7]; __pyx_v_verbose = values[8]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("listing_items_format", 0, 1, 9, __pyx_nargs); __PYX_ERR(0, 666, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.listing_items_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_14listing_items_format(__pyx_self, __pyx_v_lst, __pyx_v_begintext, __pyx_v_endtext, __pyx_v_bullet, __pyx_v_enum, __pyx_v_lstyle, __pyx_v_space, __pyx_v_inline, __pyx_v_verbose);
0669: ):
0670: """ Format list by enumerate them successively with carriage return
0671:
0672: :param lst: list,
0673: object for listening
0674: :param begintext: str,
0675: Text to display at the beginning of listing the items in `lst`.
0676: :param endtext: str,
0677: Text to display at the end of the listing items in `lst`.
0678: :param enum:bool, default=True,
0679: Count the number of items in `lst` and display it
0680: :param lstyle: str, default =None
0681: listing marker.
0682: :param bullet:str, default='-'
0683: symbol that is used to introduce item if `enum` is set to False.
0684: :param space: int,
0685: number of space to keep before each outputted item in `lst`
0686: :param inline: bool, default=False,
0687: Display all element inline rather than carriage return every times.
0688: :param verbose: bool,
0689: Always True for print. If set to False, return list of string
0690: litteral text.
0691: :returns: None or str
0692: None or string litteral if verbose is set to ``False``.
0693: Examples
0694: ---------
0695: >>> from gofast.tools.coreutils import listing_items_format
0696: >>> litems = ['hole_number', 'depth_top', 'depth_bottom', 'strata_name',
0697: 'rock_name','thickness', 'resistivity', 'gamma_gamma',
0698: 'natural_gamma', 'sp','short_distance_gamma', 'well_diameter']
0699: >>> listing_items_format (litems , 'Features' ,
0700: 'have been successfully drop.' ,
0701: lstyle ='.', space=3)
0702: """
+0703: out =''
__Pyx_TraceLine(703,0,__PYX_ERR(0, 703, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__22); __pyx_v_out = __pyx_kp_u__22;
+0704: if not is_iterable(lst):
__Pyx_TraceLine(704,0,__PYX_ERR(0, 704, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_lst}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 704, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 704, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ }
+0705: lst=[lst]
__Pyx_TraceLine(705,0,__PYX_ERR(0, 705, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_lst); __Pyx_GIVEREF(__pyx_v_lst); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_lst)) __PYX_ERR(0, 705, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_lst, __pyx_t_1); __pyx_t_1 = 0;
0706:
+0707: if hasattr (lst, '__array__'):
__Pyx_TraceLine(707,0,__PYX_ERR(0, 707, __pyx_L1_error)) __pyx_t_6 = __Pyx_HasAttr(__pyx_v_lst, __pyx_n_u_array_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 707, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+0708: if lst.ndim !=1:
__Pyx_TraceLine(708,0,__PYX_ERR(0, 708, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_lst, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_1, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 708, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_6)) { /* … */ }
+0709: raise ValueError (" Can not print multidimensional array."
__Pyx_TraceLine(709,0,__PYX_ERR(0, 709, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 709, __pyx_L1_error) /* … */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_Can_not_print_multidimensional); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 709, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31);
0710: " Expect one dimensional array.")
+0711: lst = list(lst)
__Pyx_TraceLine(711,0,__PYX_ERR(0, 711, __pyx_L1_error)) __pyx_t_1 = PySequence_List(__pyx_v_lst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_lst, __pyx_t_1); __pyx_t_1 = 0;
+0712: begintext = str(begintext); endtext=str(endtext)
__Pyx_TraceLine(712,0,__PYX_ERR(0, 712, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_begintext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_begintext, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_endtext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_endtext, __pyx_t_1); __pyx_t_1 = 0;
+0713: lstyle= lstyle or bullet
__Pyx_TraceLine(713,0,__PYX_ERR(0, 713, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_lstyle); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 713, __pyx_L1_error) if (!__pyx_t_6) { } else { __Pyx_INCREF(__pyx_v_lstyle); __pyx_t_1 = __pyx_v_lstyle; goto __pyx_L6_bool_binop_done; } __Pyx_INCREF(__pyx_v_bullet); __pyx_t_1 = __pyx_v_bullet; __pyx_L6_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_lstyle, __pyx_t_1); __pyx_t_1 = 0;
+0714: lstyle = str(lstyle)
__Pyx_TraceLine(714,0,__PYX_ERR(0, 714, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_lstyle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_lstyle, __pyx_t_1); __pyx_t_1 = 0;
+0715: b= f"{begintext +':' } "
__Pyx_TraceLine(715,0,__PYX_ERR(0, 715, __pyx_L1_error)) __pyx_t_1 = PyNumber_Add(__pyx_v_begintext, __pyx_kp_u__32); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u__14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 715, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_b = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+0716: if verbose :
__Pyx_TraceLine(716,0,__PYX_ERR(0, 716, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 716, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+0717: print(b, end=' ') if inline else (
__Pyx_TraceLine(717,0,__PYX_ERR(0, 717, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_inline); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 717, __pyx_L1_error) if (__pyx_t_6) { __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_b); __Pyx_GIVEREF(__pyx_v_b); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_b)) __PYX_ERR(0, 717, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_end, __pyx_kp_u__14) < 0) __PYX_ERR(0, 717, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } else {
+0718: print(b) if begintext!='' else None)
__Pyx_TraceLine(718,0,__PYX_ERR(0, 718, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_begintext, __pyx_kp_u__22, Py_NE)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 718, __pyx_L1_error) if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_b); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_7 = Py_None; } __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0719: out += b + ('\n' if not inline else ' ')
__Pyx_TraceLine(719,0,__PYX_ERR(0, 719, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_inline); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 719, __pyx_L1_error) __pyx_t_5 = (!__pyx_t_6); if (__pyx_t_5) { __Pyx_INCREF(__pyx_kp_u__11); __pyx_t_1 = __pyx_kp_u__11; } else { __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_1 = __pyx_kp_u__14; } __pyx_t_7 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_b, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 719, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_v_out, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 719, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_1); __pyx_t_1 = 0;
+0720: for k, item in enumerate (lst):
__Pyx_TraceLine(720,0,__PYX_ERR(0, 720, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_lst)) || PyTuple_CheckExact(__pyx_v_lst)) { __pyx_t_7 = __pyx_v_lst; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_lst); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 720, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 720, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 720, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 720, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_3); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 720, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_7); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 720, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_1); __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(720,0,__PYX_ERR(0, 720, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0721: sp = ' ' * space
__Pyx_TraceLine(721,0,__PYX_ERR(0, 721, __pyx_L1_error)) __pyx_t_3 = PyNumber_Multiply(__pyx_kp_u__14, __pyx_v_space); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_sp, __pyx_t_3); __pyx_t_3 = 0;
+0722: if ( not enum and inline ): lstyle =''
__Pyx_TraceLine(722,0,__PYX_ERR(0, 722, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_enum); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 722, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_6); if (__pyx_t_10) { } else { __pyx_t_5 = __pyx_t_10; goto __pyx_L12_bool_binop_done; } __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_inline); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 722, __pyx_L1_error) __pyx_t_5 = __pyx_t_10; __pyx_L12_bool_binop_done:; if (__pyx_t_5) { __Pyx_INCREF(__pyx_kp_u__22); __Pyx_DECREF_SET(__pyx_v_lstyle, __pyx_kp_u__22); }
+0723: o = f"{sp}{str(k+1) if enum else bullet+ ' ' }{lstyle} {item}"
__Pyx_TraceLine(723,0,__PYX_ERR(0, 723, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = 0; __pyx_t_12 = 127; __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_sp, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_enum); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 723, __pyx_L1_error) if (__pyx_t_5) { __pyx_t_13 = __Pyx_PyInt_AddObjC(__pyx_v_k, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_PyObject_Str(__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_2 = __pyx_t_14; __pyx_t_14 = 0; } else { __pyx_t_14 = PyNumber_Add(__pyx_v_bullet, __pyx_kp_u__14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_2 = __pyx_t_14; __pyx_t_14 = 0; } __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_lstyle, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_11 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_u__14); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_v_item, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_3, 5, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_o, ((PyObject*)__pyx_t_14)); __pyx_t_14 = 0;
+0724: if verbose:
__Pyx_TraceLine(724,0,__PYX_ERR(0, 724, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 724, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+0725: print (o , end=' ') if inline else print(o)
__Pyx_TraceLine(725,0,__PYX_ERR(0, 725, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_inline); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 725, __pyx_L1_error) if (__pyx_t_5) { __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_o); __Pyx_GIVEREF(__pyx_v_o); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_o)) __PYX_ERR(0, 725, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_end, __pyx_kp_u__14) < 0) __PYX_ERR(0, 725, __pyx_L1_error) __pyx_t_13 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_14 = __pyx_t_13; __pyx_t_13 = 0; } else { __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_o); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __pyx_t_13; __pyx_t_13 = 0; } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+0726: out += o + ('\n' if not inline else ' ')
__Pyx_TraceLine(726,0,__PYX_ERR(0, 726, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_inline); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 726, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_5); if (__pyx_t_10) { __Pyx_INCREF(__pyx_kp_u__11); __pyx_t_14 = __pyx_kp_u__11; } else { __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_14 = __pyx_kp_u__14; } __pyx_t_13 = __Pyx_PyUnicode_ConcatSafe(__pyx_v_o, __pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyUnicode_ConcatInPlaceSafe(__pyx_v_out, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_14); __pyx_t_14 = 0;
0727:
+0728: en= ' ' + endtext if inline else endtext
__Pyx_TraceLine(728,0,__PYX_ERR(0, 728, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_inline); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 728, __pyx_L1_error) if (__pyx_t_10) { __pyx_t_7 = PyNumber_Add(__pyx_kp_u__14, __pyx_v_endtext); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 728, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } else { __Pyx_INCREF(__pyx_v_endtext); __pyx_t_1 = __pyx_v_endtext; } __pyx_v_en = __pyx_t_1; __pyx_t_1 = 0;
+0729: if verbose:
__Pyx_TraceLine(729,0,__PYX_ERR(0, 729, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 729, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+0730: print(en) if endtext !='' else None
__Pyx_TraceLine(730,0,__PYX_ERR(0, 730, __pyx_L1_error)) __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_v_endtext, __pyx_kp_u__22, Py_NE)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 730, __pyx_L1_error) if (__pyx_t_10) { __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_en); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_1 = Py_None; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0731: out +=en
__Pyx_TraceLine(731,0,__PYX_ERR(0, 731, __pyx_L1_error)) __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_out, __pyx_v_en); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_out, __pyx_t_1); __pyx_t_1 = 0;
0732:
+0733: return None if verbose else out
__Pyx_TraceLine(733,0,__PYX_ERR(0, 733, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 733, __pyx_L1_error) if (__pyx_t_10) { __Pyx_INCREF(Py_None); __pyx_t_1 = Py_None; } else { __Pyx_INCREF(__pyx_v_out); __pyx_t_1 = __pyx_v_out; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0734:
0735:
+0736: def parse_attrs (attr, regex=None ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_17parse_attrs(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_16parse_attrs, " Parse attributes using the regular expression.\n \n Remove all string non-alphanumeric and some operator indicators, and \n fetch attributes names. \n \n Parameters \n -----------\n \n attr: str, text litteral containing the attributes \n names \n \n regex: `re` object, default is \n Regular expresion object. the default is:: \n \n >>> import re \n >>> re.compile (r'per|mod|times|add|sub|[_#&*@!_,;\\s-]\\s*', \n flags=re.IGNORECASE) \n Returns\n -------\n attr: List of attributes \n \n Example\n ---------\n >>> from gofast.tools.coreutils import parse_attrs \n >>> parse_attrs('lwi_sub_ohmSmulmagnitude')\n ... ['lwi', 'ohmS', 'magnitude']\n \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_17parse_attrs = {"parse_attrs", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_17parse_attrs, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_16parse_attrs}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_17parse_attrs(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_attr = 0; PyObject *__pyx_v_regex = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("parse_attrs (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_attr,&__pyx_n_s_regex,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_attr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 736, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 736, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "parse_attrs") < 0)) __PYX_ERR(0, 736, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_attr = values[0]; __pyx_v_regex = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parse_attrs", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 736, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.parse_attrs", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_16parse_attrs(__pyx_self, __pyx_v_attr, __pyx_v_regex); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_16parse_attrs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_attr, PyObject *__pyx_v_regex) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__33) __Pyx_TraceCall("parse_attrs", __pyx_f[0], 736, 0, __PYX_ERR(0, 736, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_attr); __Pyx_INCREF(__pyx_v_regex); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.parse_attrs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_attr); __Pyx_XDECREF(__pyx_v_regex); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__362 = PyTuple_Pack(2, __pyx_n_s_attr, __pyx_n_s_regex); if (unlikely(!__pyx_tuple__362)) __PYX_ERR(0, 736, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__362); __Pyx_GIVEREF(__pyx_tuple__362); /* … */ __Pyx_TraceLine(736,0,__PYX_ERR(0, 736, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_17parse_attrs, 0, __pyx_n_s_parse_attrs, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__33)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 736, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__62); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_attrs, __pyx_t_4) < 0) __PYX_ERR(0, 736, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__33 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__362, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parse_attrs, 736, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__33)) __PYX_ERR(0, 736, __pyx_L1_error)
0737: """ Parse attributes using the regular expression.
0738:
0739: Remove all string non-alphanumeric and some operator indicators, and
0740: fetch attributes names.
0741:
0742: Parameters
0743: -----------
0744:
0745: attr: str, text litteral containing the attributes
0746: names
0747:
0748: regex: `re` object, default is
0749: Regular expresion object. the default is::
0750:
0751: >>> import re
0752: >>> re.compile (r'per|mod|times|add|sub|[_#&*@!_,;\s-]\s*',
0753: flags=re.IGNORECASE)
0754: Returns
0755: -------
0756: attr: List of attributes
0757:
0758: Example
0759: ---------
0760: >>> from gofast.tools.coreutils import parse_attrs
0761: >>> parse_attrs('lwi_sub_ohmSmulmagnitude')
0762: ... ['lwi', 'ohmS', 'magnitude']
0763:
0764:
0765: """
+0766: regex = regex or re.compile (r'per|mod|times|add|sub|[_#&*@!_,;\s-]\s*',
__Pyx_TraceLine(766,0,__PYX_ERR(0, 766, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_regex); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 766, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_regex); __pyx_t_1 = __pyx_v_regex; goto __pyx_L3_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_compile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(766,0,__PYX_ERR(0, 766, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__34, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_t_6); __pyx_t_1 = __pyx_t_6; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_L3_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_regex, __pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_u_per_mod_times_add_sub_____s_s); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 766, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34);
+0767: flags=re.IGNORECASE)
__Pyx_TraceLine(767,0,__PYX_ERR(0, 767, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_re); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_flags, __pyx_t_6) < 0) __PYX_ERR(0, 767, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0768: attr= list(filter (None, regex.split(attr)))
__Pyx_TraceLine(768,0,__PYX_ERR(0, 768, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_regex, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_attr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, Py_None)) __PYX_ERR(0, 768, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_filter, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_attr, __pyx_t_6); __pyx_t_6 = 0;
+0769: return attr
__Pyx_TraceLine(769,0,__PYX_ERR(0, 769, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_attr); __pyx_r = __pyx_v_attr; goto __pyx_L0;
0770:
+0771: def url_checker (url: str , install:bool = False,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_19url_checker(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_18url_checker, "\n check whether the URL is reachable or not. \n \n function uses the requests library. If not install, set the `install` \n parameter to ``True`` to subprocess install it. \n \n Parameters \n ------------\n url: str, \n link to the url for checker whether it is reachable \n install: bool, \n Action to install the 'requests' module if module is not install yet.\n raises: str \n raise errors when url is not recheable rather than returning ``0``.\n if `raises` is ``ignore``, and module 'requests' is not installed, it \n will use the django url validator. However, the latter only assert \n whether url is right but not validate its reachability. \n \n Returns\n --------\n ``True``{1} for reacheable and ``False``{0} otherwise. \n \n Example\n ----------\n >>> from gofast.tools.coreutils import url_checker \n >>> url_checker (\"http://www.example.com\")\n ... 0 # not reacheable \n >>> url_checker (\"https://gofast.readthedocs.io/en/latest/api/gofast.html\")\n ... 1 \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_19url_checker = {"url_checker", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_19url_checker, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_18url_checker}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_19url_checker(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_url = 0; PyObject *__pyx_v_install = 0; PyObject *__pyx_v_raises = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("url_checker (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_url,&__pyx_n_s_install,&__pyx_n_s_raises,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_ignore))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_url)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 771, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_install); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 771, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raises); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 771, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "url_checker") < 0)) __PYX_ERR(0, 771, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_url = ((PyObject*)values[0]); __pyx_v_install = values[1]; __pyx_v_raises = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("url_checker", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 771, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.url_checker", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyUnicode_Type), 0, "url", 1))) __PYX_ERR(0, 771, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_raises), (&PyUnicode_Type), 0, "raises", 1))) __PYX_ERR(0, 772, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_18url_checker(__pyx_self, __pyx_v_url, __pyx_v_install, __pyx_v_raises); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18url_checker(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url, PyObject *__pyx_v_install, PyObject *__pyx_v_raises) { long __pyx_v_isr; PyObject *__pyx_v_success = NULL; PyObject *__pyx_v_regex = NULL; PyObject *__pyx_v_requests = NULL; PyObject *__pyx_v_get = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__35) __Pyx_TraceCall("url_checker", __pyx_f[0], 771, 0, __PYX_ERR(0, 771, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.url_checker", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_success); __Pyx_XDECREF(__pyx_v_regex); __Pyx_XDECREF(__pyx_v_requests); __Pyx_XDECREF(__pyx_v_get); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__363 = PyTuple_Pack(9, __pyx_n_s_url, __pyx_n_s_install, __pyx_n_s_raises, __pyx_n_s_isr, __pyx_n_s_success, __pyx_n_s_regex, __pyx_n_s_requests, __pyx_n_s_get, __pyx_n_s_e); if (unlikely(!__pyx_tuple__363)) __PYX_ERR(0, 771, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__363); __Pyx_GIVEREF(__pyx_tuple__363); __pyx_codeobj__35 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__363, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_url_checker, 771, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__35)) __PYX_ERR(0, 771, __pyx_L1_error) /* … */ __Pyx_TraceLine(771,0,__PYX_ERR(0, 771, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 771, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_url, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 771, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_install, __pyx_n_s_bool) < 0) __PYX_ERR(0, 771, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_raises, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 771, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 771, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_19url_checker, 0, __pyx_n_s_url_checker, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__35)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 771, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__364); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_url_checker, __pyx_t_2) < 0) __PYX_ERR(0, 771, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__364 = PyTuple_Pack(2, ((PyObject *)Py_False), ((PyObject*)__pyx_n_u_ignore)); if (unlikely(!__pyx_tuple__364)) __PYX_ERR(0, 771, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__364); __Pyx_GIVEREF(__pyx_tuple__364);
0772: raises:str ='ignore')-> bool :
0773: """
0774: check whether the URL is reachable or not.
0775:
0776: function uses the requests library. If not install, set the `install`
0777: parameter to ``True`` to subprocess install it.
0778:
0779: Parameters
0780: ------------
0781: url: str,
0782: link to the url for checker whether it is reachable
0783: install: bool,
0784: Action to install the 'requests' module if module is not install yet.
0785: raises: str
0786: raise errors when url is not recheable rather than returning ``0``.
0787: if `raises` is ``ignore``, and module 'requests' is not installed, it
0788: will use the django url validator. However, the latter only assert
0789: whether url is right but not validate its reachability.
0790:
0791: Returns
0792: --------
0793: ``True``{1} for reacheable and ``False``{0} otherwise.
0794:
0795: Example
0796: ----------
0797: >>> from gofast.tools.coreutils import url_checker
0798: >>> url_checker ("http://www.example.com")
0799: ... 0 # not reacheable
0800: >>> url_checker ("https://gofast.readthedocs.io/en/latest/api/gofast.html")
0801: ... 1
0802:
0803: """
+0804: isr =0 ; success = False
__Pyx_TraceLine(804,0,__PYX_ERR(0, 804, __pyx_L1_error)) __pyx_v_isr = 0; __Pyx_INCREF(Py_False); __pyx_v_success = Py_False;
0805:
+0806: regex = re.compile(
__Pyx_TraceLine(806,0,__PYX_ERR(0, 806, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0807: r'^(?:http|ftp)s?://' # http:// or https://
0808: #domain...
0809: r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'
0810: r'localhost|' #localhost...
0811: r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
0812: r'(?::\d+)?' # optional port
+0813: r'(?:/?|[/?]\S+)$', re.IGNORECASE
__Pyx_TraceLine(813,0,__PYX_ERR(0, 813, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_kp_u_http_ftp_s_A_Z0_9_A_Z0_9_0_61_A, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_regex = __pyx_t_1; __pyx_t_1 = 0;
0814: )
0815:
+0816: try :
__Pyx_TraceLine(816,0,__PYX_ERR(0, 816, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L8_try_end:; }
+0817: import requests
__Pyx_TraceLine(817,0,__PYX_ERR(0, 817, __pyx_L3_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_requests, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 817, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_requests = __pyx_t_1; __pyx_t_1 = 0;
+0818: except ImportError:
__Pyx_TraceLine(818,0,__PYX_ERR(0, 818, __pyx_L5_except_error)) __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils.url_checker", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 818, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4);
+0819: if install:
__Pyx_TraceLine(819,0,__PYX_ERR(0, 819, __pyx_L5_except_error)) __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_install); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 819, __pyx_L5_except_error) if (__pyx_t_9) { /* … */ }
+0820: success = is_installing('requests', DEVNULL=True)
__Pyx_TraceLine(820,0,__PYX_ERR(0, 820, __pyx_L5_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_installing); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 820, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 820, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_DEVNULL, Py_True) < 0) __PYX_ERR(0, 820, __pyx_L5_except_error) __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__37, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 820, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_success, __pyx_t_11); __pyx_t_11 = 0; /* … */ __pyx_tuple__37 = PyTuple_Pack(1, __pyx_n_u_requests); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 820, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__37); __Pyx_GIVEREF(__pyx_tuple__37);
+0821: if not success:
__Pyx_TraceLine(821,0,__PYX_ERR(0, 821, __pyx_L5_except_error)) __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_success); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 821, __pyx_L5_except_error) __pyx_t_12 = (!__pyx_t_9); if (__pyx_t_12) { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error;
+0822: if raises=='raises':
__Pyx_TraceLine(822,0,__PYX_ERR(0, 822, __pyx_L5_except_error)) __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_raises, __pyx_n_u_raises, Py_EQ)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 822, __pyx_L5_except_error) if (unlikely(__pyx_t_12)) { /* … */ }
+0823: raise ModuleNotFoundError(
__Pyx_TraceLine(823,0,__PYX_ERR(0, 823, __pyx_L5_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_ModuleNotFoundError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 823, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__38, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 823, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 823, __pyx_L5_except_error) /* … */ __pyx_tuple__38 = PyTuple_Pack(1, __pyx_kp_u_auto_installation_of_requests_fa); if (unlikely(!__pyx_tuple__38)) __PYX_ERR(0, 823, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__38); __Pyx_GIVEREF(__pyx_tuple__38);
0824: "auto-installation of 'requests' failed."
0825: " Install it mannually.")
0826:
+0827: else : success=True
__Pyx_TraceLine(827,0,__PYX_ERR(0, 827, __pyx_L5_except_error)) /*else:*/ { __Pyx_INCREF(Py_True); __Pyx_DECREF_SET(__pyx_v_success, Py_True); } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
0828:
+0829: if success:
__Pyx_TraceLine(829,0,__PYX_ERR(0, 829, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_success); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 829, __pyx_L1_error) if (__pyx_t_12) { /* … */ }
+0830: try:
__Pyx_TraceLine(830,0,__PYX_ERR(0, 830, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L20_try_end; __pyx_L15_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L17_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L1_error; __pyx_L16_exception_handled:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); __pyx_L20_try_end:; }
+0831: get = requests.get(url) #Get Url
__Pyx_TraceLine(831,0,__PYX_ERR(0, 831, __pyx_L15_error)) if (unlikely(!__pyx_v_requests)) { __Pyx_RaiseUnboundLocalError("requests"); __PYX_ERR(0, 831, __pyx_L15_error) } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_requests, __pyx_n_s_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 831, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_url}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 831, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_get = __pyx_t_4; __pyx_t_4 = 0;
+0832: if get.status_code == 200: # if the request succeeds
__Pyx_TraceLine(832,0,__PYX_ERR(0, 832, __pyx_L15_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_get, __pyx_n_s_status_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 832, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_12 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_4, __pyx_int_200, 0xC8, 0)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 832, __pyx_L15_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_12) { /* … */ goto __pyx_L21; }
+0833: isr =1 # (f"{url}: is reachable")
__Pyx_TraceLine(833,0,__PYX_ERR(0, 833, __pyx_L15_error)) __pyx_v_isr = 1;
0834:
0835: else:
+0836: warnings.warn(
__Pyx_TraceLine(836,0,__PYX_ERR(0, 836, __pyx_L15_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_warnings); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 836, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_warn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 836, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0837: f"{url}: is not reachable, status_code: {get.status_code}")
__Pyx_TraceLine(837,0,__PYX_ERR(0, 837, __pyx_L15_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 837, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_v_url); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_url) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_url) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_url); __Pyx_INCREF(__pyx_kp_u_is_not_reachable_status_code); __pyx_t_13 += 33; __Pyx_GIVEREF(__pyx_kp_u_is_not_reachable_status_code); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u_is_not_reachable_status_code); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_get, __pyx_n_s_status_code); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 837, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 837, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 837, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_11}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 836, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0838: isr =0
__Pyx_TraceLine(838,0,__PYX_ERR(0, 838, __pyx_L15_error)) __pyx_v_isr = 0; } __pyx_L21:;
0839:
+0840: except requests.exceptions.RequestException as e:
__Pyx_TraceLine(840,0,__PYX_ERR(0, 840, __pyx_L17_except_error)) __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_1, &__pyx_t_11); if (unlikely(!__pyx_v_requests)) { __Pyx_RaiseUnboundLocalError("requests"); __PYX_ERR(0, 840, __pyx_L17_except_error) } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_requests, __pyx_n_s_exceptions); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 840, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_RequestException); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 840, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_ErrRestore(__pyx_t_4, __pyx_t_1, __pyx_t_11); __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_11 = 0; if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils.url_checker", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 840, __pyx_L17_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; /*try:*/ { /* … */ __Pyx_TraceLine(840,0,__PYX_ERR(0, 840, __pyx_L27_error)) /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L28; } __pyx_L27_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __pyx_t_5 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22); } __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16; goto __pyx_L17_except_error; } __pyx_L28:; } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L16_exception_handled; } goto __pyx_L17_except_error;
+0841: if raises=='raises':
__Pyx_TraceLine(841,0,__PYX_ERR(0, 841, __pyx_L27_error)) __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_raises, __pyx_n_u_raises, Py_EQ)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 841, __pyx_L27_error) if (unlikely(__pyx_t_12)) { /* … */ }
+0842: raise SystemExit(f"{url}: is not reachable \nErr: {e}")
__Pyx_TraceLine(842,0,__PYX_ERR(0, 842, __pyx_L27_error)) __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 842, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_v_url); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_url) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_url) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_url); __Pyx_INCREF(__pyx_kp_u_is_not_reachable_Err); __pyx_t_13 += 25; __Pyx_GIVEREF(__pyx_kp_u_is_not_reachable_Err); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_kp_u_is_not_reachable_Err); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 842, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_SystemExit, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 842, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 842, __pyx_L27_error)
+0843: else: isr =0
__Pyx_TraceLine(843,0,__PYX_ERR(0, 843, __pyx_L27_error)) /*else*/ { __pyx_v_isr = 0; } }
0844:
+0845: if not success :
__Pyx_TraceLine(845,0,__PYX_ERR(0, 845, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_success); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 845, __pyx_L1_error) __pyx_t_9 = (!__pyx_t_12); if (__pyx_t_9) { /* … */ }
0846: # use django url validation regex
0847: # https://github.com/django/django/blob/stable/1.3.x/django/core/validators.py#L45
+0848: isr = 1 if re.match(regex, url) is not None else 0
__Pyx_TraceLine(848,0,__PYX_ERR(0, 848, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_match); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_15 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_15 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_v_regex, __pyx_v_url}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_15, 2+__pyx_t_15); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_9 = (__pyx_t_4 != Py_None); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_9) { __pyx_t_23 = 1; } else { __pyx_t_23 = 0; } __pyx_v_isr = __pyx_t_23;
0849:
+0850: return isr
__Pyx_TraceLine(850,0,__PYX_ERR(0, 850, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_isr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
0851:
+0852: def shrunkformat(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_308__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 852, 0, __PYX_ERR(0, 852, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(856,0,__PYX_ERR(0, 856, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_chunksize);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_chunksize);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self)->__pyx_arg_chunksize)) __PYX_ERR(0, 852, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None)) __PYX_ERR(0, 852, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None)) __PYX_ERR(0, 852, __pyx_L1_error);
/* … */
__Pyx_TraceLine(852,0,__PYX_ERR(0, 852, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 852, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 852, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_21shrunkformat(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_20shrunkformat, " Format class and add ellipsis when classes are greater than maxview \n \n :param text: str - a text to shrunk and format. Can also be an iterable\n object. \n :param chunksize: int, the size limit to keep in the formatage text. *default* \n is ``7``.\n :param insert_at: str, the place to insert the ellipsis. If ``None``, \n shrunk the text and put the ellipsis, between the text beginning and \n the text endpoint. Can be ``beginning``, or ``end``. \n :param sep: str if the text is delimited by a kind of character, the `sep` \n parameters could be usefull so it would become a starting point for \n word counting. *default* is `None` which means word is counting from \n the space. \n \n :example: \n \n >>> import numpy as np \n >>> from gofast.tools.coreutils import shrunkformat\n >>> text=\" I'm a long text and I will be shrunked and replaced by ellipsis.\"\n >>> shrunkformat (text)\n ... 'Im a long ... and replaced by ellipsis.'\n >>> shrunkformat (text, insert_at ='end')\n ...'Im a long ... '\n >>> arr = np.arange(30)\n >>> shrunkformat (arr, chunksize=10 )\n ... '0 1 2 3 4 ... 25 26 27 28 29'\n >>> shrunkformat (arr, insert_at ='begin')\n ... ' ... 26 27 28 29'\n \n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_21shrunkformat = {"shrunkformat", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_21shrunkformat, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_20shrunkformat};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_21shrunkformat(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_text = 0;
PyObject *__pyx_v_chunksize = 0;
PyObject *__pyx_v_insert_at = 0;
PyObject *__pyx_v_sep = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("shrunkformat (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_text,&__pyx_n_s_chunksize,&__pyx_n_s_insert_at,&__pyx_n_s_sep,0};
PyObject* values[4] = {0,0,0,0};
__pyx_defaults1 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_self);
values[1] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_chunksize);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_20shrunkformat(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text, PyObject *__pyx_v_chunksize, PyObject *__pyx_v_insert_at, PyObject *__pyx_v_sep) {
int __pyx_v_is_str;
PyObject *__pyx_v_regex = NULL;
PyObject *__pyx_v_gp = NULL;
PyObject *__pyx_v_textsplt = NULL;
PyObject *__pyx_v_rl = NULL;
PyObject *__pyx_v_ll = NULL;
PyObject *__pyx_v_spllst = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__39)
__Pyx_TraceCall("shrunkformat", __pyx_f[0], 852, 0, __PYX_ERR(0, 852, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_chunksize);
__Pyx_INCREF(__pyx_v_insert_at);
__Pyx_INCREF(__pyx_v_sep);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("gofast.tools.coreutils.shrunkformat", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_regex);
__Pyx_XDECREF(__pyx_v_gp);
__Pyx_XDECREF(__pyx_v_textsplt);
__Pyx_XDECREF(__pyx_v_rl);
__Pyx_XDECREF(__pyx_v_ll);
__Pyx_XDECREF(__pyx_v_spllst);
__Pyx_XDECREF(__pyx_v_chunksize);
__Pyx_XDECREF(__pyx_v_insert_at);
__Pyx_XDECREF(__pyx_v_sep);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__365 = PyTuple_Pack(11, __pyx_n_s_text, __pyx_n_s_chunksize, __pyx_n_s_insert_at, __pyx_n_s_sep, __pyx_n_s_is_str, __pyx_n_s_regex, __pyx_n_s_gp, __pyx_n_s_textsplt, __pyx_n_s_rl, __pyx_n_s_ll, __pyx_n_s_spllst); if (unlikely(!__pyx_tuple__365)) __PYX_ERR(0, 852, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__365);
__Pyx_GIVEREF(__pyx_tuple__365);
/* … */
__Pyx_TraceLine(852,0,__PYX_ERR(0, 852, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 852, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_text, __pyx_kp_s_Union_str_Iterable_Any) < 0) __PYX_ERR(0, 852, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_chunksize, __pyx_n_s_int) < 0) __PYX_ERR(0, 852, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_insert_at, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 852, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_sep, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 852, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_None) < 0) __PYX_ERR(0, 852, __pyx_L1_error)
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_21shrunkformat, 0, __pyx_n_s_shrunkformat, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__39)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 852, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults1), 1)) __PYX_ERR(0, 852, __pyx_L1_error)
__pyx_codeobj__39 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__365, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_shrunkformat, 852, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__39)) __PYX_ERR(0, 852, __pyx_L1_error)
0853: text: Union[str, Iterable[Any]],
+0854: chunksize: int = 7,
__Pyx_TraceLine(854,0,__PYX_ERR(0, 854, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_7)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_7))) __PYX_ERR(0, 854, __pyx_L1_error) __Pyx_INCREF(__pyx_int_7); __Pyx_CyFunction_Defaults(__pyx_defaults1, __pyx_t_4)->__pyx_arg_chunksize = ((PyObject*)__pyx_int_7); __Pyx_GIVEREF(__pyx_int_7); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_6gofast_5tools_9coreutils_308__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_shrunkformat, __pyx_t_4) < 0) __PYX_ERR(0, 852, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+0855: insert_at: Optional[str] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+0856: sep: Optional[str] = None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_text)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_chunksize); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_insert_at); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sep); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "shrunkformat") < 0)) __PYX_ERR(0, 852, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_text = values[0]; __pyx_v_chunksize = ((PyObject*)values[1]); __pyx_v_insert_at = values[2]; __pyx_v_sep = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("shrunkformat", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 852, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.shrunkformat", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_chunksize), (&PyInt_Type), 0, "chunksize", 1))) __PYX_ERR(0, 854, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_20shrunkformat(__pyx_self, __pyx_v_text, __pyx_v_chunksize, __pyx_v_insert_at, __pyx_v_sep);
0857: ) -> None:
0858: """ Format class and add ellipsis when classes are greater than maxview
0859:
0860: :param text: str - a text to shrunk and format. Can also be an iterable
0861: object.
0862: :param chunksize: int, the size limit to keep in the formatage text. *default*
0863: is ``7``.
0864: :param insert_at: str, the place to insert the ellipsis. If ``None``,
0865: shrunk the text and put the ellipsis, between the text beginning and
0866: the text endpoint. Can be ``beginning``, or ``end``.
0867: :param sep: str if the text is delimited by a kind of character, the `sep`
0868: parameters could be usefull so it would become a starting point for
0869: word counting. *default* is `None` which means word is counting from
0870: the space.
0871:
0872: :example:
0873:
0874: >>> import numpy as np
0875: >>> from gofast.tools.coreutils import shrunkformat
0876: >>> text=" I'm a long text and I will be shrunked and replaced by ellipsis."
0877: >>> shrunkformat (text)
0878: ... 'Im a long ... and replaced by ellipsis.'
0879: >>> shrunkformat (text, insert_at ='end')
0880: ...'Im a long ... '
0881: >>> arr = np.arange(30)
0882: >>> shrunkformat (arr, chunksize=10 )
0883: ... '0 1 2 3 4 ... 25 26 27 28 29'
0884: >>> shrunkformat (arr, insert_at ='begin')
0885: ... ' ... 26 27 28 29'
0886:
0887: """
+0888: is_str = False
__Pyx_TraceLine(888,0,__PYX_ERR(0, 888, __pyx_L1_error)) __pyx_v_is_str = 0;
+0889: chunksize = int (_assert_all_types(chunksize, float, int))
__Pyx_TraceLine(889,0,__PYX_ERR(0, 889, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_v_chunksize, ((PyObject *)(&PyFloat_Type)), ((PyObject *)(&PyInt_Type))}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_2)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_2))) __PYX_ERR(0, 889, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_chunksize, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
0890:
+0891: regex = re.compile (r"(begin|start|beg)|(end|close|last)")
__Pyx_TraceLine(891,0,__PYX_ERR(0, 891, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_u_begin_start_beg_end_close_last}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_regex = __pyx_t_2; __pyx_t_2 = 0;
+0892: insert_at = str(insert_at).lower().strip()
__Pyx_TraceLine(892,0,__PYX_ERR(0, 892, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_insert_at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_insert_at, __pyx_t_2); __pyx_t_2 = 0;
+0893: gp = regex.search (insert_at)
__Pyx_TraceLine(893,0,__PYX_ERR(0, 893, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_regex, __pyx_n_s_search); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_insert_at}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 893, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_gp = __pyx_t_2; __pyx_t_2 = 0;
+0894: if gp is not None:
__Pyx_TraceLine(894,0,__PYX_ERR(0, 894, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_gp != Py_None); if (__pyx_t_6) { /* … */ }
+0895: if gp.group (1) is not None:
__Pyx_TraceLine(895,0,__PYX_ERR(0, 895, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gp, __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 895, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_int_1}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 895, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_6 = (__pyx_t_2 != Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ goto __pyx_L4; }
+0896: insert_at ='begin'
__Pyx_TraceLine(896,0,__PYX_ERR(0, 896, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_begin); __Pyx_DECREF_SET(__pyx_v_insert_at, __pyx_n_u_begin);
+0897: elif gp.group(2) is not None:
__Pyx_TraceLine(897,0,__PYX_ERR(0, 897, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_gp, __pyx_n_s_group); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_int_2}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_6 = (__pyx_t_2 != Py_None); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ } __pyx_L4:;
+0898: insert_at ='end'
__Pyx_TraceLine(898,0,__PYX_ERR(0, 898, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_end); __Pyx_DECREF_SET(__pyx_v_insert_at, __pyx_n_u_end);
+0899: if insert_at is None:
__Pyx_TraceLine(899,0,__PYX_ERR(0, 899, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_insert_at == Py_None); if (__pyx_t_6) { /* … */ }
+0900: warnings.warn(f"Expect ['begining'|'end'], got {insert_at!r}"
__Pyx_TraceLine(900,0,__PYX_ERR(0, 900, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_warnings); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Expect_begining_end_got); __pyx_t_7 += 31; __Pyx_GIVEREF(__pyx_kp_u_Expect_begining_end_got); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Expect_begining_end_got); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_insert_at), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_Default_value_is_used_instead); __pyx_t_7 += 31; __Pyx_GIVEREF(__pyx_kp_u_Default_value_is_used_instead); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_Default_value_is_used_instead); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_5, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_1}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0901: " Default value is used instead.")
+0902: if isinstance(text , str):
__Pyx_TraceLine(902,0,__PYX_ERR(0, 902, __pyx_L1_error)) __pyx_t_6 = PyUnicode_Check(__pyx_v_text); if (__pyx_t_6) { /* … */ goto __pyx_L6; }
+0903: textsplt = text.strip().split(sep) # put text on list
__Pyx_TraceLine(903,0,__PYX_ERR(0, 903, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_text, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 903, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 903, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 903, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_sep}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 903, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_textsplt = __pyx_t_2; __pyx_t_2 = 0;
+0904: is_str =True
__Pyx_TraceLine(904,0,__PYX_ERR(0, 904, __pyx_L1_error)) __pyx_v_is_str = 1;
0905:
+0906: elif hasattr (text , '__iter__'):
__Pyx_TraceLine(906,0,__PYX_ERR(0, 906, __pyx_L1_error)) __pyx_t_6 = __Pyx_HasAttr(__pyx_v_text, __pyx_n_u_iter); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 906, __pyx_L1_error) if (__pyx_t_6) { /* … */ } __pyx_L6:;
+0907: textsplt = list(text )
__Pyx_TraceLine(907,0,__PYX_ERR(0, 907, __pyx_L1_error)) __pyx_t_2 = PySequence_List(__pyx_v_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_textsplt = __pyx_t_2; __pyx_t_2 = 0;
0908:
+0909: if len(textsplt) < chunksize :
__Pyx_TraceLine(909,0,__PYX_ERR(0, 909, __pyx_L1_error)) if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 909, __pyx_L1_error) } __pyx_t_7 = PyObject_Length(__pyx_v_textsplt); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 909, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_v_chunksize, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 909, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 909, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+0910: return text
__Pyx_TraceLine(910,0,__PYX_ERR(0, 910, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_text); __pyx_r = __pyx_v_text; goto __pyx_L0;
0911:
+0912: if is_str :
__Pyx_TraceLine(912,0,__PYX_ERR(0, 912, __pyx_L1_error)) if (__pyx_v_is_str) { /* … */ goto __pyx_L8; }
+0913: rl = textsplt [:len(textsplt)//2][: chunksize//2]
__Pyx_TraceLine(913,0,__PYX_ERR(0, 913, __pyx_L1_error)) if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 913, __pyx_L1_error) } if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 913, __pyx_L1_error) } __pyx_t_7 = PyObject_Length(__pyx_v_textsplt); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 913, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_textsplt, 0, __Pyx_div_Py_ssize_t(__pyx_t_7, 2), NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_FloorDivide(__pyx_v_chunksize, __pyx_int_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_1, 0, 0, NULL, &__pyx_t_2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_rl = __pyx_t_3; __pyx_t_3 = 0;
+0914: ll= textsplt [len(textsplt)//2:][-chunksize//2:]
__Pyx_TraceLine(914,0,__PYX_ERR(0, 914, __pyx_L1_error)) if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 914, __pyx_L1_error) } if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 914, __pyx_L1_error) } __pyx_t_7 = PyObject_Length(__pyx_v_textsplt); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 914, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_textsplt, __Pyx_div_Py_ssize_t(__pyx_t_7, 2), 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Negative(__pyx_v_chunksize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_t_3, 0, 0, &__pyx_t_1, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_ll = __pyx_t_2; __pyx_t_2 = 0;
0915:
+0916: if sep is None: sep =' '
__Pyx_TraceLine(916,0,__PYX_ERR(0, 916, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_sep == Py_None); if (__pyx_t_6) { __Pyx_INCREF(__pyx_kp_u__14); __Pyx_DECREF_SET(__pyx_v_sep, __pyx_kp_u__14); }
+0917: spllst = [f'{sep}'.join ( rl), f'{sep}'.join ( ll)]
__Pyx_TraceLine(917,0,__PYX_ERR(0, 917, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_sep, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyUnicode_Join(((PyObject*)__pyx_t_2), __pyx_v_rl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_sep, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyUnicode_Join(((PyObject*)__pyx_t_2), __pyx_v_ll); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 917, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3)) __PYX_ERR(0, 917, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_v_spllst = __pyx_t_2; __pyx_t_2 = 0;
0918:
+0919: else : spllst = [
__Pyx_TraceLine(919,0,__PYX_ERR(0, 919, __pyx_L1_error)) /*else*/ { /* … */ __Pyx_TraceLine(919,0,__PYX_ERR(0, 919, __pyx_L1_error)) __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3)) __PYX_ERR(0, 919, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_2)) __PYX_ERR(0, 919, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_v_spllst = __pyx_t_1; __pyx_t_1 = 0; } __pyx_L8:;
+0920: textsplt[: chunksize//2 ] ,textsplt[-chunksize//2:]
__Pyx_TraceLine(920,0,__PYX_ERR(0, 920, __pyx_L1_error)) if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 920, __pyx_L1_error) } __pyx_t_2 = PyNumber_FloorDivide(__pyx_v_chunksize, __pyx_int_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_textsplt, 0, 0, NULL, &__pyx_t_2, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_v_textsplt)) { __Pyx_RaiseUnboundLocalError("textsplt"); __PYX_ERR(0, 920, __pyx_L1_error) } __pyx_t_2 = PyNumber_Negative(__pyx_v_chunksize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyInt_FloorDivideObjC(__pyx_t_2, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_textsplt, 0, 0, &__pyx_t_1, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
0921: ]
+0922: if insert_at =='begin':
__Pyx_TraceLine(922,0,__PYX_ERR(0, 922, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_insert_at, __pyx_n_u_begin, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 922, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L10; }
+0923: spllst.insert(0, ' ... ') ; spllst.pop(1)
__Pyx_TraceLine(923,0,__PYX_ERR(0, 923, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_spllst, __pyx_n_s_insert); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_PopIndex(__pyx_v_spllst, __pyx_int_1, 1, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 923, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__41 = PyTuple_Pack(2, __pyx_int_0, __pyx_kp_u__40); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 923, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__41); __Pyx_GIVEREF(__pyx_tuple__41);
+0924: elif insert_at =='end':
__Pyx_TraceLine(924,0,__PYX_ERR(0, 924, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_insert_at, __pyx_n_u_end, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 924, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L10; }
+0925: spllst.pop(-1) ; spllst.extend ([' ... '])
__Pyx_TraceLine(925,0,__PYX_ERR(0, 925, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_PopIndex(__pyx_v_spllst, __pyx_int_neg_1, -1L, 1, Py_ssize_t, PyInt_FromSsize_t); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 925, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_spllst, __pyx_n_s_extend); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 925, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 925, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_u__40); __Pyx_GIVEREF(__pyx_kp_u__40); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u__40)) __PYX_ERR(0, 925, __pyx_L1_error); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 925, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0926:
0927: else :
+0928: spllst.insert (1, ' ... ')
__Pyx_TraceLine(928,0,__PYX_ERR(0, 928, __pyx_L1_error)) /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_spllst, __pyx_n_s_insert); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__42, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 928, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L10:; /* … */ __pyx_tuple__42 = PyTuple_Pack(2, __pyx_int_1, __pyx_kp_u__40); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 928, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42);
0929:
+0930: spllst = spllst if is_str else str(spllst)
__Pyx_TraceLine(930,0,__PYX_ERR(0, 930, __pyx_L1_error)) if (__pyx_v_is_str) { __Pyx_INCREF(__pyx_v_spllst); __pyx_t_1 = __pyx_v_spllst; } else { __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_spllst); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_spllst, __pyx_t_1); __pyx_t_1 = 0;
0931:
+0932: return re.sub(r"[\[,'\]]", '', ''.join(spllst),
__Pyx_TraceLine(932,0,__PYX_ERR(0, 932, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__22, __pyx_v_spllst); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_kp_u__43); __Pyx_GIVEREF(__pyx_kp_u__43); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u__43)) __PYX_ERR(0, 932, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__22); __Pyx_GIVEREF(__pyx_kp_u__22); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u__22)) __PYX_ERR(0, 932, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1)) __PYX_ERR(0, 932, __pyx_L1_error); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(932,0,__PYX_ERR(0, 932, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0;
+0933: flags=re.IGNORECASE
__Pyx_TraceLine(933,0,__PYX_ERR(0, 933, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_re); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_flags, __pyx_t_9) < 0) __PYX_ERR(0, 933, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
0934: )
0935:
+0936: def is_installing (
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_310__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 936, 0, __PYX_ERR(0, 936, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(940,0,__PYX_ERR(0, 940, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)Py_True));
__Pyx_GIVEREF(((PyObject *)Py_True));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_True))) __PYX_ERR(0, 936, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_True));
__Pyx_GIVEREF(((PyObject *)Py_True));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_True))) __PYX_ERR(0, 936, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)Py_False))) __PYX_ERR(0, 936, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_verbose);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_verbose);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self)->__pyx_arg_verbose)) __PYX_ERR(0, 936, __pyx_L1_error);
/* … */
__Pyx_TraceLine(936,0,__PYX_ERR(0, 936, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 936, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 936, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 936, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_23is_installing(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_22is_installing, " Install or uninstall a module/package using the subprocess \n under the hood.\n \n Parameters \n ------------\n module: str,\n the module or library name to install using Python Index Package `PIP`\n \n upgrade: bool,\n install the lastest version of the package. *default* is ``True``. \n \n DEVNULL:bool, \n decline the stdoutput the message in the console \n \n action: str,bool \n Action to perform. 'install' or 'uninstall' a package. *default* is \n ``True`` which means 'intall'. \n \n verbose: int, Optional\n Control the verbosity i.e output a message. High level \n means more messages. *default* is ``0``.\n \n subpkws: dict, \n additional subprocess keywords arguments \n Returns \n ---------\n success: bool \n whether the package is sucessfully installed or not. \n \n Example\n --------\n >>> from gofast import is_installing\n >>> is_installing(\n 'tqdm', action ='install', DEVNULL=True, verbose =1)\n >>> is_installing(\n 'tqdm', action ='uninstall', verbose =1)\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_23is_installing = {"is_installing", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_23is_installing, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_22is_installing};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_23is_installing(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_module = 0;
PyObject *__pyx_v_upgrade = 0;
PyObject *__pyx_v_action = 0;
PyObject *__pyx_v_DEVNULL = 0;
PyObject *__pyx_v_verbose = 0;
PyObject *__pyx_v_subpkws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("is_installing (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_subpkws = PyDict_New(); if (unlikely(!__pyx_v_subpkws)) return NULL;
__Pyx_GOTREF(__pyx_v_subpkws);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_module,&__pyx_n_s_upgrade,&__pyx_n_s_action,&__pyx_n_s_DEVNULL,&__pyx_n_s_verbose,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults2 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_self);
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_verbose);
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_module)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 936, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_upgrade);
if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 936, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_action);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 936, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_DEVNULL);
if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 936, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose);
if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 936, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_subpkws, values + 0, kwd_pos_args, "is_installing") < 0)) __PYX_ERR(0, 936, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_module = ((PyObject*)values[0]);
__pyx_v_upgrade = values[1];
__pyx_v_action = values[2];
__pyx_v_DEVNULL = values[3];
__pyx_v_verbose = ((PyObject*)values[4]);
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("is_installing", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 936, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_DECREF(__pyx_v_subpkws); __pyx_v_subpkws = 0;
__Pyx_AddTraceback("gofast.tools.coreutils.is_installing", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_module), (&PyUnicode_Type), 0, "module", 1))) __PYX_ERR(0, 937, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_verbose), (&PyInt_Type), 0, "verbose", 1))) __PYX_ERR(0, 941, __pyx_L1_error)
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_22is_installing(__pyx_self, __pyx_v_module, __pyx_v_upgrade, __pyx_v_action, __pyx_v_DEVNULL, __pyx_v_verbose, __pyx_v_subpkws);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_subpkws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_22is_installing(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_module, PyObject *__pyx_v_upgrade, PyObject *__pyx_v_action, PyObject *__pyx_v_DEVNULL, PyObject *__pyx_v_verbose, PyObject *__pyx_v_subpkws) {
int __pyx_v_success;
PyObject *__pyx_v_action_msg = NULL;
PyObject *__pyx_v_cmdg = NULL;
PyObject *__pyx_v_cmd = NULL;
PyObject *__pyx_v_STDOUT = NULL;
PyObject *__pyx_v_STDERR = NULL;
PyObject *__pyx_v_reqs = NULL;
PyObject *__pyx_8genexpr7__pyx_v_r = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__44)
__Pyx_TraceCall("is_installing", __pyx_f[0], 936, 0, __PYX_ERR(0, 936, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_upgrade);
__Pyx_INCREF(__pyx_v_action);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_15);
__Pyx_XDECREF(__pyx_t_16);
__Pyx_AddTraceback("gofast.tools.coreutils.is_installing", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_action_msg);
__Pyx_XDECREF(__pyx_v_cmdg);
__Pyx_XDECREF(__pyx_v_cmd);
__Pyx_XDECREF(__pyx_v_STDOUT);
__Pyx_XDECREF(__pyx_v_STDERR);
__Pyx_XDECREF(__pyx_v_reqs);
__Pyx_XDECREF(__pyx_8genexpr7__pyx_v_r);
__Pyx_XDECREF(__pyx_v_upgrade);
__Pyx_XDECREF(__pyx_v_action);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__366 = PyTuple_Pack(14, __pyx_n_s_module, __pyx_n_s_upgrade, __pyx_n_s_action, __pyx_n_s_DEVNULL, __pyx_n_s_verbose, __pyx_n_s_subpkws, __pyx_n_s_success, __pyx_n_s_action_msg, __pyx_n_s_cmdg, __pyx_n_s_cmd, __pyx_n_s_STDOUT, __pyx_n_s_STDERR, __pyx_n_s_reqs, __pyx_n_s_r); if (unlikely(!__pyx_tuple__366)) __PYX_ERR(0, 936, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__366);
__Pyx_GIVEREF(__pyx_tuple__366);
/* … */
__Pyx_TraceLine(936,0,__PYX_ERR(0, 936, __pyx_L1_error))
__pyx_t_4 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 936, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_module, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_upgrade, __pyx_n_s_bool) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_action, __pyx_n_s_bool) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_DEVNULL, __pyx_n_s_bool) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_verbose, __pyx_n_s_int) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 936, __pyx_L1_error)
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_23is_installing, 0, __pyx_n_s_is_installing, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__44)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 936, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults2), 1)) __PYX_ERR(0, 936, __pyx_L1_error)
__pyx_codeobj__44 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__366, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_installing, 936, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__44)) __PYX_ERR(0, 936, __pyx_L1_error)
0937: module: str ,
0938: upgrade: bool=True ,
0939: action: bool=True,
0940: DEVNULL: bool=False,
+0941: verbose: int=0,
__Pyx_TraceLine(941,0,__PYX_ERR(0, 941, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_0)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_0))) __PYX_ERR(0, 941, __pyx_L1_error) __Pyx_INCREF(__pyx_int_0); __Pyx_CyFunction_Defaults(__pyx_defaults2, __pyx_t_2)->__pyx_arg_verbose = ((PyObject*)__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_6gofast_5tools_9coreutils_310__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_installing, __pyx_t_2) < 0) __PYX_ERR(0, 936, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0942: **subpkws
0943: )-> bool:
0944: """ Install or uninstall a module/package using the subprocess
0945: under the hood.
0946:
0947: Parameters
0948: ------------
0949: module: str,
0950: the module or library name to install using Python Index Package `PIP`
0951:
0952: upgrade: bool,
0953: install the lastest version of the package. *default* is ``True``.
0954:
0955: DEVNULL:bool,
0956: decline the stdoutput the message in the console
0957:
0958: action: str,bool
0959: Action to perform. 'install' or 'uninstall' a package. *default* is
0960: ``True`` which means 'intall'.
0961:
0962: verbose: int, Optional
0963: Control the verbosity i.e output a message. High level
0964: means more messages. *default* is ``0``.
0965:
0966: subpkws: dict,
0967: additional subprocess keywords arguments
0968: Returns
0969: ---------
0970: success: bool
0971: whether the package is sucessfully installed or not.
0972:
0973: Example
0974: --------
0975: >>> from gofast import is_installing
0976: >>> is_installing(
0977: 'tqdm', action ='install', DEVNULL=True, verbose =1)
0978: >>> is_installing(
0979: 'tqdm', action ='uninstall', verbose =1)
0980: """
0981: #implement pip as subprocess
0982: # refer to https://pythongeeks.org/subprocess-in-python/
+0983: if not action:
__Pyx_TraceLine(983,0,__PYX_ERR(0, 983, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_action); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 983, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0984: if verbose > 0 :
__Pyx_TraceLine(984,0,__PYX_ERR(0, 984, __pyx_L1_error)) __pyx_t_3 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 984, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 984, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+0985: print("---> No action `install`or `uninstall`"
__Pyx_TraceLine(985,0,__PYX_ERR(0, 985, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_No_action_install_or_uninstall); __pyx_t_4 += 53; __Pyx_GIVEREF(__pyx_kp_u_No_action_install_or_uninstall); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_No_action_install_or_uninstall); /* … */ __Pyx_TraceLine(985,0,__PYX_ERR(0, 985, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0986: f" of the module {module!r} performed.")
__Pyx_TraceLine(986,0,__PYX_ERR(0, 986, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_module), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 986, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u_performed); __pyx_t_4 += 11; __Pyx_GIVEREF(__pyx_kp_u_performed); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_performed);
+0987: return action # DO NOTHING
__Pyx_TraceLine(987,0,__PYX_ERR(0, 987, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_action); __pyx_r = __pyx_v_action; goto __pyx_L0;
0988:
+0989: success=False
__Pyx_TraceLine(989,0,__PYX_ERR(0, 989, __pyx_L1_error)) __pyx_v_success = 0;
0990:
+0991: action_msg ='uninstallation' if action =='uninstall' else 'installation'
__Pyx_TraceLine(991,0,__PYX_ERR(0, 991, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_action, __pyx_n_u_uninstall, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 991, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_n_u_uninstallation); __pyx_t_3 = __pyx_n_u_uninstallation; } else { __Pyx_INCREF(__pyx_n_u_installation); __pyx_t_3 = __pyx_n_u_installation; } __pyx_v_action_msg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
0992:
+0993: if action in ('install', 'uninstall', True) and verbose > 0:
__Pyx_TraceLine(993,0,__PYX_ERR(0, 993, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_action); __pyx_t_3 = __pyx_v_action; __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_install, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 993, __pyx_L1_error) if (!__pyx_t_7) { } else { __pyx_t_1 = __pyx_t_7; goto __pyx_L8_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_uninstall, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 993, __pyx_L1_error) if (!__pyx_t_7) { } else { __pyx_t_1 = __pyx_t_7; goto __pyx_L8_bool_binop_done; } __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 993, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 993, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __pyx_t_7; __pyx_L8_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __pyx_t_1; if (__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L6_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 993, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 993, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_7; __pyx_L6_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+0994: print(f'---> Module {module!r} {action_msg} will take a while,'
__Pyx_TraceLine(994,0,__PYX_ERR(0, 994, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Module); __pyx_t_4 += 12; __Pyx_GIVEREF(__pyx_kp_u_Module); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Module); __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_module), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__14); __pyx_t_6 = __Pyx_PyUnicode_Unicode(__pyx_v_action_msg); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u_will_take_a_while_please_be_pat); __pyx_t_4 += 40; __Pyx_GIVEREF(__pyx_kp_u_will_take_a_while_please_be_pat); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u_will_take_a_while_please_be_pat); __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_3, 5, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0995: ' please be patient...')
0996:
+0997: cmdg =f'<pip install {module}> | <python -m pip install {module}>'\
__Pyx_TraceLine(997,0,__PYX_ERR(0, 997, __pyx_L1_error)) __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_pip_install); __pyx_t_4 += 13; __Pyx_GIVEREF(__pyx_kp_u_pip_install); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_pip_install); __Pyx_INCREF(__pyx_v_module); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_module); __Pyx_INCREF(__pyx_kp_u_python_m_pip_install); __pyx_t_4 += 27; __Pyx_GIVEREF(__pyx_kp_u_python_m_pip_install); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_python_m_pip_install); __Pyx_INCREF(__pyx_v_module); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_module); __Pyx_INCREF(__pyx_kp_u__45); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__45); PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_kp_u__45); __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_6, 5, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = __pyx_t_8; __pyx_t_8 = 0; } else {
+0998: if action in (True, 'install') else ''.join([
__Pyx_TraceLine(998,0,__PYX_ERR(0, 998, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_action); __pyx_t_6 = __pyx_v_action; __pyx_t_8 = PyObject_RichCompare(__pyx_t_6, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 998, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 998, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L11_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_n_u_install, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 998, __pyx_L1_error) __pyx_t_2 = __pyx_t_7; __pyx_L11_bool_binop_done:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __pyx_t_2; if (__pyx_t_7) { /* … */ __Pyx_TraceLine(998,0,__PYX_ERR(0, 998, __pyx_L1_error)) __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_6)) __PYX_ERR(0, 998, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_9)) __PYX_ERR(0, 998, __pyx_L1_error); __pyx_t_6 = 0; __pyx_t_9 = 0; __pyx_t_9 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_3 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_v_cmdg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+0999: f'<pip uninstall {module} -y> or <pip3 uninstall {module} -y ',
__Pyx_TraceLine(999,0,__PYX_ERR(0, 999, __pyx_L1_error)) __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_pip_uninstall); __pyx_t_4 += 15; __Pyx_GIVEREF(__pyx_kp_u_pip_uninstall); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_pip_uninstall); __Pyx_INCREF(__pyx_v_module); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_module); __Pyx_INCREF(__pyx_kp_u_y_or_pip3_uninstall); __pyx_t_4 += 24; __Pyx_GIVEREF(__pyx_kp_u_y_or_pip3_uninstall); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u_y_or_pip3_uninstall); __Pyx_INCREF(__pyx_v_module); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_v_module); __Pyx_INCREF(__pyx_kp_u_y); __pyx_t_4 += 4; __Pyx_GIVEREF(__pyx_kp_u_y); PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_kp_u_y); __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_8, 5, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1000: f'or <python -m pip uninstall {module} -y>.'])
__Pyx_TraceLine(1000,0,__PYX_ERR(0, 1000, __pyx_L1_error)) __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_or_python_m_pip_uninstall); __pyx_t_4 += 28; __Pyx_GIVEREF(__pyx_kp_u_or_python_m_pip_uninstall); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_or_python_m_pip_uninstall); __Pyx_INCREF(__pyx_v_module); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_module); __Pyx_INCREF(__pyx_kp_u_y_2); __pyx_t_4 += 5; __Pyx_GIVEREF(__pyx_kp_u_y_2); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u_y_2); __pyx_t_9 = __Pyx_PyUnicode_Join(__pyx_t_8, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1001:
+1002: upgrade ='--upgrade' if upgrade else ''
__Pyx_TraceLine(1002,0,__PYX_ERR(0, 1002, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_upgrade); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1002, __pyx_L1_error) if (__pyx_t_7) { __Pyx_INCREF(__pyx_kp_u_upgrade_2); __pyx_t_3 = __pyx_kp_u_upgrade_2; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_3 = __pyx_kp_u__22; } __Pyx_DECREF_SET(__pyx_v_upgrade, __pyx_t_3); __pyx_t_3 = 0;
1003:
+1004: if action == 'uninstall':
__Pyx_TraceLine(1004,0,__PYX_ERR(0, 1004, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_action, __pyx_n_u_uninstall, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1004, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L13; }
+1005: upgrade= '-y' # Don't ask for confirmation of uninstall deletions.
__Pyx_TraceLine(1005,0,__PYX_ERR(0, 1005, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_y_3); __Pyx_DECREF_SET(__pyx_v_upgrade, __pyx_kp_u_y_3);
+1006: elif action in ('install', True):
__Pyx_TraceLine(1006,0,__PYX_ERR(0, 1006, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_action); __pyx_t_3 = __pyx_v_action; __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_install, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1006, __pyx_L1_error) if (!__pyx_t_2) { } else { __pyx_t_7 = __pyx_t_2; goto __pyx_L14_bool_binop_done; } __pyx_t_9 = PyObject_RichCompare(__pyx_t_3, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1006, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1006, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_7 = __pyx_t_2; __pyx_L14_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_7; if (__pyx_t_2) { /* … */ } __pyx_L13:;
+1007: action = 'install'
__Pyx_TraceLine(1007,0,__PYX_ERR(0, 1007, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_install); __Pyx_DECREF_SET(__pyx_v_action, __pyx_n_u_install);
1008:
+1009: cmd = ['-m', 'pip', f'{action}', f'{module}', f'{upgrade}']
__Pyx_TraceLine(1009,0,__PYX_ERR(0, 1009, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_action, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_v_upgrade, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = PyList_New(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1009, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_kp_u_m); __Pyx_GIVEREF(__pyx_kp_u_m); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_m)) __PYX_ERR(0, 1009, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_pip); __Pyx_GIVEREF(__pyx_n_u_pip); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 1, __pyx_n_u_pip)) __PYX_ERR(0, 1009, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 2, __pyx_t_3)) __PYX_ERR(0, 1009, __pyx_L1_error); __Pyx_INCREF(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 3, __pyx_v_module)) __PYX_ERR(0, 1009, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 4, __pyx_t_9)) __PYX_ERR(0, 1009, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_9 = 0; __pyx_v_cmd = ((PyObject*)__pyx_t_8); __pyx_t_8 = 0;
1010:
+1011: try:
__Pyx_TraceLine(1011,0,__PYX_ERR(0, 1011, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L18_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L1_error; __pyx_L17_exception_handled:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_L21_try_end:; }
+1012: STDOUT = subprocess.DEVNULL if DEVNULL else None
__Pyx_TraceLine(1012,0,__PYX_ERR(0, 1012, __pyx_L16_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_DEVNULL); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1012, __pyx_L16_error) if (__pyx_t_2) { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_subprocess); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1012, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_DEVNULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1012, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_8 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_8 = Py_None; } __pyx_v_STDOUT = __pyx_t_8; __pyx_t_8 = 0;
+1013: STDERR= subprocess.STDOUT if DEVNULL else None
__Pyx_TraceLine(1013,0,__PYX_ERR(0, 1013, __pyx_L16_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_DEVNULL); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1013, __pyx_L16_error) if (__pyx_t_2) { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_subprocess); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1013, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_STDOUT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1013, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __pyx_t_9; __pyx_t_9 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_8 = Py_None; } __pyx_v_STDERR = __pyx_t_8; __pyx_t_8 = 0;
1014:
+1015: subprocess.check_call(
__Pyx_TraceLine(1015,0,__PYX_ERR(0, 1015, __pyx_L16_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_subprocess); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1015, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_check_call); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1015, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(1015,0,__PYX_ERR(0, 1015, __pyx_L16_error)) __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1015, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3)) __PYX_ERR(0, 1015, __pyx_L16_error); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(1015,0,__PYX_ERR(0, 1015, __pyx_L16_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1015, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+1016: [sys.executable] + cmd, stdout= STDOUT, stderr=STDERR,
__Pyx_TraceLine(1016,0,__PYX_ERR(0, 1016, __pyx_L16_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_sys); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1016, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_executable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1016, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1016, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_3)) __PYX_ERR(0, 1016, __pyx_L16_error); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_t_8, __pyx_v_cmd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1016, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(1016,0,__PYX_ERR(0, 1016, __pyx_L16_error)) __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1016, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_stdout, __pyx_v_STDOUT) < 0) __PYX_ERR(0, 1016, __pyx_L16_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_stderr, __pyx_v_STDERR) < 0) __PYX_ERR(0, 1016, __pyx_L16_error) __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0;
+1017: **subpkws)
__Pyx_TraceLine(1017,0,__PYX_ERR(0, 1017, __pyx_L16_error)) if (__Pyx_MergeKeywords(__pyx_t_3, __pyx_v_subpkws) < 0) __PYX_ERR(0, 1017, __pyx_L16_error)
+1018: if action in (True, 'install'):
__Pyx_TraceLine(1018,0,__PYX_ERR(0, 1018, __pyx_L16_error)) __Pyx_INCREF(__pyx_v_action); __pyx_t_6 = __pyx_v_action; __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1018, __pyx_L16_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1018, __pyx_L16_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L23_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_n_u_install, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1018, __pyx_L16_error) __pyx_t_2 = __pyx_t_7; __pyx_L23_bool_binop_done:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = __pyx_t_2; if (__pyx_t_7) { /* … */ }
1019: # freeze the dependancies
+1020: reqs = subprocess.check_output(
__Pyx_TraceLine(1020,0,__PYX_ERR(0, 1020, __pyx_L16_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_subprocess); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1020, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_check_output); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1020, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1021: [sys.executable,'-m', 'pip','freeze'])
__Pyx_TraceLine(1021,0,__PYX_ERR(0, 1021, __pyx_L16_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1021, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_executable); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1021, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1021, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_9)) __PYX_ERR(0, 1021, __pyx_L16_error); __Pyx_INCREF(__pyx_kp_u_m); __Pyx_GIVEREF(__pyx_kp_u_m); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u_m)) __PYX_ERR(0, 1021, __pyx_L16_error); __Pyx_INCREF(__pyx_n_u_pip); __Pyx_GIVEREF(__pyx_n_u_pip); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 2, __pyx_n_u_pip)) __PYX_ERR(0, 1021, __pyx_L16_error); __Pyx_INCREF(__pyx_n_u_freeze); __Pyx_GIVEREF(__pyx_n_u_freeze); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 3, __pyx_n_u_freeze)) __PYX_ERR(0, 1021, __pyx_L16_error); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_3}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1020, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_v_reqs = __pyx_t_6; __pyx_t_6 = 0;
+1022: [r.decode().split('==')[0] for r in reqs.split()]
__Pyx_TraceLine(1022,0,__PYX_ERR(0, 1022, __pyx_L16_error)) { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_reqs, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_13, 0+__pyx_t_13); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) { __pyx_t_3 = __pyx_t_8; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_14 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1022, __pyx_L27_error) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1022, __pyx_L27_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 1022, __pyx_L27_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1022, __pyx_L27_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_8); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 1022, __pyx_L27_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1022, __pyx_L27_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_8genexpr7__pyx_v_r, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr7__pyx_v_r, __pyx_n_s_decode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_16, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_13, 0+__pyx_t_13); __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_split); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_kp_u__46}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 1022, __pyx_L27_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_r); __pyx_8genexpr7__pyx_v_r = 0; goto __pyx_L31_exit_scope; __pyx_L27_error:; __Pyx_XDECREF(__pyx_8genexpr7__pyx_v_r); __pyx_8genexpr7__pyx_v_r = 0; goto __pyx_L16_error; __pyx_L31_exit_scope:; } /* exit inner scope */ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1023:
+1024: success=True
__Pyx_TraceLine(1024,0,__PYX_ERR(0, 1024, __pyx_L16_error)) __pyx_v_success = 1;
1025:
+1026: except:
__Pyx_TraceLine(1026,0,__PYX_ERR(0, 1026, __pyx_L18_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.is_installing", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_15, &__pyx_t_3) < 0) __PYX_ERR(0, 1026, __pyx_L18_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_3);
1027:
+1028: if verbose > 0 :
__Pyx_TraceLine(1028,0,__PYX_ERR(0, 1028, __pyx_L18_except_error)) __pyx_t_8 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1028, __pyx_L18_except_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1028, __pyx_L18_except_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_7) { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L17_exception_handled; }
+1029: print(f'---> Module {module!r} {action_msg} failed. Please use'
__Pyx_TraceLine(1029,0,__PYX_ERR(0, 1029, __pyx_L18_except_error)) __pyx_t_8 = PyTuple_New(7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1029, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Module); __pyx_t_4 += 12; __Pyx_GIVEREF(__pyx_kp_u_Module); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u_Module); __pyx_t_9 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_module), __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1029, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u__14); __pyx_t_9 = __Pyx_PyUnicode_Unicode(__pyx_v_action_msg); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1029, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_failed_Please_use_the_following); __pyx_t_4 += 43; __Pyx_GIVEREF(__pyx_kp_u_failed_Please_use_the_following); PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_kp_u_failed_Please_use_the_following); /* … */ __Pyx_TraceLine(1029,0,__PYX_ERR(0, 1029, __pyx_L18_except_error)) __pyx_t_9 = __Pyx_PyUnicode_Join(__pyx_t_8, 7, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1029, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1029, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1030: f' the following command: {cmdg} to manually do it.')
__Pyx_TraceLine(1030,0,__PYX_ERR(0, 1030, __pyx_L18_except_error)) __pyx_t_9 = __Pyx_PyUnicode_Unicode(__pyx_v_cmdg); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1030, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_to_manually_do_it); __pyx_t_4 += 19; __Pyx_GIVEREF(__pyx_kp_u_to_manually_do_it); PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_kp_u_to_manually_do_it);
1031: else :
+1032: if verbose > 0:
__Pyx_TraceLine(1032,0,__PYX_ERR(0, 1032, __pyx_L18_except_error)) /*else:*/ { __pyx_t_6 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1032, __pyx_L18_except_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1032, __pyx_L18_except_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_7) { /* … */ } } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L21_try_end; __pyx_L16_error:; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
+1033: print(f"{action_msg.capitalize()} of `{module}` "
__Pyx_TraceLine(1033,0,__PYX_ERR(0, 1033, __pyx_L18_except_error)) __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1033, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = 0; __pyx_t_5 = 127; __pyx_t_3 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_capitalize, __pyx_v_action_msg); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1033, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1033, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15); __pyx_t_15 = 0; __Pyx_INCREF(__pyx_kp_u_of); __pyx_t_4 += 5; __Pyx_GIVEREF(__pyx_kp_u_of); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_kp_u_of); __Pyx_INCREF(__pyx_v_module); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_module) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_module); __Pyx_GIVEREF(__pyx_v_module); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_module); __Pyx_INCREF(__pyx_kp_u_and_dependancies_was_successful); __pyx_t_4 += 41; __Pyx_GIVEREF(__pyx_kp_u_and_dependancies_was_successful); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_kp_u_and_dependancies_was_successful); __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_6, 4, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1033, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_15); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1033, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1034: "and dependancies was successfully done!")
1035:
+1036: return success
__Pyx_TraceLine(1036,0,__PYX_ERR(0, 1036, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_success); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1036, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1037:
+1038: def smart_strobj_recognition(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_25smart_strobj_recognition(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_24smart_strobj_recognition, " Find the likelihood word in the whole containers and \n returns the value.\n \n :param name: str - Value of to search. I can not match the exact word in \n the `container`\n :param container: list, tuple, dict- container of the many string words. \n :param stripitems: str - 'str' items values to sanitize the content \n element of the dummy containers. if different items are provided, they \n can be separated by ``:``, ``,`` and ``;``. The items separators \n aforementioned can not be used as a component in the `name`. For \n isntance:: \n \n name= 'dipole_'; stripitems='_' -> means remove the '_'\n under the ``dipole_``\n name= '+dipole__'; stripitems ='+;__'-> means remove the '+' and\n '__' under the value `name`. \n \n :param deep: bool - Kind of research. Go deeper by looping each items \n for find the initials that can fit the name. Note that, if given, \n the first occurence should be consider as the best name... \n \n :return: Likelihood object from `container` or Nonetype if none object is\n detected.\n \n :Example:\n >>> from gofast.tools.coreutils import smart_strobj_recognition\n >>> from gofast.methods import ResistivityProfiling \n >>> rObj = ResistivityProfiling(AB= 200, MN= 20,)\n >>> smart_strobj_recognition ('dip', robj.__dict__))\n ... None \n >>> smart_strobj_recognition ('dipole_', robj.__dict__))\n ... dipole \n >>> smart_strobj_recognition ('dip', robj.__dict__,deep=True )\n ... dipole \n >>> smart_strobj_recognition (\n '+_dipole___', robj.__dict__,deep=True , stripitems ='+;_')\n ... 'dipole'\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_25smart_strobj_recognition = {"smart_strobj_recognition", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_25smart_strobj_recognition, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_24smart_strobj_recognition}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_25smart_strobj_recognition(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_name = 0; PyObject *__pyx_v_container = 0; PyObject *__pyx_v_stripitems = 0; PyObject *__pyx_v_deep = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("smart_strobj_recognition (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name_2,&__pyx_n_s_container,&__pyx_n_s_stripitems,&__pyx_n_s_deep,0}; PyObject* values[4] = {0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u__8))); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_24smart_strobj_recognition(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_container, PyObject *__pyx_v_stripitems, PyObject *__pyx_v_deep) { PyObject *__pyx_v_ix = NULL; PyObject *__pyx_v_rv = NULL; PyObject *__pyx_v_sep = NULL; PyObject *__pyx_v_s = NULL; PyObject *__pyx_v_container_ = NULL; PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_n = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__47) __Pyx_TraceCall("smart_strobj_recognition", __pyx_f[0], 1038, 0, __PYX_ERR(0, 1038, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_name); __Pyx_INCREF(__pyx_v_container); __Pyx_INCREF(__pyx_v_stripitems); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils.smart_strobj_recognition", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ix); __Pyx_XDECREF(__pyx_v_rv); __Pyx_XDECREF(__pyx_v_sep); __Pyx_XDECREF(__pyx_v_s); __Pyx_XDECREF(__pyx_v_container_); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_container); __Pyx_XDECREF(__pyx_v_stripitems); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__367 = PyTuple_Pack(11, __pyx_n_s_name_2, __pyx_n_s_container, __pyx_n_s_stripitems, __pyx_n_s_deep, __pyx_n_s_ix, __pyx_n_s_rv, __pyx_n_s_sep, __pyx_n_s_s_2, __pyx_n_s_container_2, __pyx_n_s_ii, __pyx_n_s_n); if (unlikely(!__pyx_tuple__367)) __PYX_ERR(0, 1038, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__367); __Pyx_GIVEREF(__pyx_tuple__367); __pyx_codeobj__47 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__367, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_smart_strobj_recognition, 1038, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__47)) __PYX_ERR(0, 1038, __pyx_L1_error) /* … */ __Pyx_TraceLine(1038,0,__PYX_ERR(0, 1038, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_name_2, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1038, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_container, __pyx_kp_s_Union_List_Tuple_Dict_Any_Any) < 0) __PYX_ERR(0, 1038, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_stripitems, __pyx_kp_s_Union_str_List_Tuple) < 0) __PYX_ERR(0, 1038, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_deep, __pyx_n_s_bool) < 0) __PYX_ERR(0, 1038, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1038, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_25smart_strobj_recognition, 0, __pyx_n_s_smart_strobj_recognition, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__47)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__368); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_smart_strobj_recognition, __pyx_t_4) < 0) __PYX_ERR(0, 1038, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__368 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u__8), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__368)) __PYX_ERR(0, 1038, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__368); __Pyx_GIVEREF(__pyx_tuple__368);
1039: name: str ,
1040: container: Union [List , Tuple , Dict[Any, Any ]],
1041: stripitems: Union [str , List , Tuple] = '_',
+1042: deep: bool = False,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1038, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_container)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1038, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("smart_strobj_recognition", 0, 2, 4, 1); __PYX_ERR(0, 1038, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_stripitems); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1038, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1038, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "smart_strobj_recognition") < 0)) __PYX_ERR(0, 1038, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = ((PyObject*)values[0]); __pyx_v_container = values[1]; __pyx_v_stripitems = values[2]; __pyx_v_deep = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("smart_strobj_recognition", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 1038, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.smart_strobj_recognition", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyUnicode_Type), 0, "name", 1))) __PYX_ERR(0, 1039, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_24smart_strobj_recognition(__pyx_self, __pyx_v_name, __pyx_v_container, __pyx_v_stripitems, __pyx_v_deep);
1043: ) -> str :
1044: """ Find the likelihood word in the whole containers and
1045: returns the value.
1046:
1047: :param name: str - Value of to search. I can not match the exact word in
1048: the `container`
1049: :param container: list, tuple, dict- container of the many string words.
1050: :param stripitems: str - 'str' items values to sanitize the content
1051: element of the dummy containers. if different items are provided, they
1052: can be separated by ``:``, ``,`` and ``;``. The items separators
1053: aforementioned can not be used as a component in the `name`. For
1054: isntance::
1055:
1056: name= 'dipole_'; stripitems='_' -> means remove the '_'
1057: under the ``dipole_``
1058: name= '+dipole__'; stripitems ='+;__'-> means remove the '+' and
1059: '__' under the value `name`.
1060:
1061: :param deep: bool - Kind of research. Go deeper by looping each items
1062: for find the initials that can fit the name. Note that, if given,
1063: the first occurence should be consider as the best name...
1064:
1065: :return: Likelihood object from `container` or Nonetype if none object is
1066: detected.
1067:
1068: :Example:
1069: >>> from gofast.tools.coreutils import smart_strobj_recognition
1070: >>> from gofast.methods import ResistivityProfiling
1071: >>> rObj = ResistivityProfiling(AB= 200, MN= 20,)
1072: >>> smart_strobj_recognition ('dip', robj.__dict__))
1073: ... None
1074: >>> smart_strobj_recognition ('dipole_', robj.__dict__))
1075: ... dipole
1076: >>> smart_strobj_recognition ('dip', robj.__dict__,deep=True )
1077: ... dipole
1078: >>> smart_strobj_recognition (
1079: '+_dipole___', robj.__dict__,deep=True , stripitems ='+;_')
1080: ... 'dipole'
1081:
1082: """
1083:
+1084: stripitems =_assert_all_types(stripitems , str, list, tuple)
__Pyx_TraceLine(1084,0,__PYX_ERR(0, 1084, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_v_stripitems, ((PyObject *)(&PyUnicode_Type)), ((PyObject *)(&PyList_Type)), ((PyObject *)(&PyTuple_Type))}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 4+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_stripitems, __pyx_t_1); __pyx_t_1 = 0;
+1085: container = _assert_all_types(container, list, tuple, dict)
__Pyx_TraceLine(1085,0,__PYX_ERR(0, 1085, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_v_container, ((PyObject *)(&PyList_Type)), ((PyObject *)(&PyTuple_Type)), ((PyObject *)(&PyDict_Type))}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 4+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_container, __pyx_t_1); __pyx_t_1 = 0;
+1086: ix , rv = None , None
__Pyx_TraceLine(1086,0,__PYX_ERR(0, 1086, __pyx_L1_error)) __pyx_t_1 = Py_None; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = Py_None; __Pyx_INCREF(__pyx_t_2); __pyx_v_ix = __pyx_t_1; __pyx_t_1 = 0; __pyx_v_rv = __pyx_t_2; __pyx_t_2 = 0;
1087:
+1088: if isinstance (stripitems , str):
__Pyx_TraceLine(1088,0,__PYX_ERR(0, 1088, __pyx_L1_error)) __pyx_t_5 = PyUnicode_Check(__pyx_v_stripitems); if (__pyx_t_5) { /* … */ }
+1089: for sep in (':', ",", ";"): # when strip ='a,b,c' seperated object
__Pyx_TraceLine(1089,0,__PYX_ERR(0, 1089, __pyx_L1_error)) __pyx_t_2 = __pyx_tuple__50; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; for (;;) { if (__pyx_t_6 >= 3) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1089, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_sep, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1089,0,__PYX_ERR(0, 1089, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L7_for_end; __pyx_L5_break:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L7_for_end; __pyx_L7_for_end:; /* … */ __pyx_tuple__50 = PyTuple_Pack(3, __pyx_kp_u__32, __pyx_kp_u__48, __pyx_kp_u__49); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 1089, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__50); __Pyx_GIVEREF(__pyx_tuple__50);
+1090: if sep in stripitems:
__Pyx_TraceLine(1090,0,__PYX_ERR(0, 1090, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_v_sep, __pyx_v_stripitems, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1090, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+1091: stripitems = stripitems.strip().split(sep) ; break
__Pyx_TraceLine(1091,0,__PYX_ERR(0, 1091, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_stripitems, __pyx_n_s_strip); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_sep}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF_SET(__pyx_v_stripitems, __pyx_t_1); __pyx_t_1 = 0; goto __pyx_L5_break;
+1092: if isinstance(stripitems, str):
__Pyx_TraceLine(1092,0,__PYX_ERR(0, 1092, __pyx_L1_error)) __pyx_t_5 = PyUnicode_Check(__pyx_v_stripitems); if (__pyx_t_5) { /* … */ }
+1093: stripitems =[stripitems]
__Pyx_TraceLine(1093,0,__PYX_ERR(0, 1093, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_stripitems); __Pyx_GIVEREF(__pyx_v_stripitems); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_stripitems)) __PYX_ERR(0, 1093, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_stripitems, __pyx_t_2); __pyx_t_2 = 0;
1094:
1095: # sanitize the name.
+1096: for s in stripitems :
__Pyx_TraceLine(1096,0,__PYX_ERR(0, 1096, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_stripitems)) || PyTuple_CheckExact(__pyx_v_stripitems)) { __pyx_t_2 = __pyx_v_stripitems; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_9 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_stripitems); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1096, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1096, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1096, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1096, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1096, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1096, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1096,0,__PYX_ERR(0, 1096, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1097: name = name.strip(s)
__Pyx_TraceLine(1097,0,__PYX_ERR(0, 1097, __pyx_L1_error)) __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_strip, __pyx_v_name, __pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1097, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1097, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_name, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
1098:
+1099: if isinstance(container, dict) :
__Pyx_TraceLine(1099,0,__PYX_ERR(0, 1099, __pyx_L1_error)) __pyx_t_5 = PyDict_Check(__pyx_v_container); if (__pyx_t_5) { /* … */ goto __pyx_L12; }
1100: #get only the key values and lower them
+1101: container_ = list(map (lambda x :x.lower(), container.keys()))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_24smart_strobj_recognition_lambda2(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_24smart_strobj_recognition_lambda2 = {"lambda2", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_24smart_strobj_recognition_lambda2, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_24smart_strobj_recognition_lambda2(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_x = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda2 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1101, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda2") < 0)) __PYX_ERR(0, 1101, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_x = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda2", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1101, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.smart_strobj_recognition.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda2(__pyx_self, __pyx_v_x);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda2(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda2", __pyx_f[0], 1101, 0, __PYX_ERR(0, 1101, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = NULL;
__pyx_t_4 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_3)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_4 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("gofast.tools.coreutils.smart_strobj_recognition.lambda2", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(1101,0,__PYX_ERR(0, 1101, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_24smart_strobj_recognition_lambda2, 0, __pyx_n_s_smart_strobj_recognition_locals, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_container, __pyx_n_s_keys); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_3 = NULL;
__pyx_t_4 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_7))) {
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
if (likely(__pyx_t_3)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_7, function);
__pyx_t_4 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
}
__pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_2);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2)) __PYX_ERR(0, 1101, __pyx_L1_error);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error);
__pyx_t_2 = 0;
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1101, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_container_ = ((PyObject*)__pyx_t_7);
__pyx_t_7 = 0;
1102: else :
1103: # for consistency put on list if values are in tuple.
+1104: container_ = list(container)
__Pyx_TraceLine(1104,0,__PYX_ERR(0, 1104, __pyx_L1_error)) /*else*/ { __pyx_t_7 = PySequence_List(__pyx_v_container); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_container_ = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0; } __pyx_L12:;
1105:
1106: # sanitize our dummny container item ...
1107: #container_ = [it.strip(s) for it in container_ for s in stripitems ]
+1108: if name.lower() in container_:
__Pyx_TraceLine(1108,0,__PYX_ERR(0, 1108, __pyx_L1_error)) __pyx_t_7 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_lower, __pyx_v_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = (__Pyx_PySequence_ContainsTF(__pyx_t_7, __pyx_v_container_, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_5) { /* … */ }
+1109: try:
__Pyx_TraceLine(1109,0,__PYX_ERR(0, 1109, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L19_try_end; __pyx_L14_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L16_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L1_error; __pyx_L19_try_end:; }
+1110: ix = container_.index (name)
__Pyx_TraceLine(1110,0,__PYX_ERR(0, 1110, __pyx_L14_error)) __pyx_t_7 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyList_Type_index, __pyx_v_container_, __pyx_v_name); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1110, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_ix, __pyx_t_7); __pyx_t_7 = 0;
+1111: except ValueError:
__Pyx_TraceLine(1111,0,__PYX_ERR(0, 1111, __pyx_L16_except_error)) __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_4) { __Pyx_AddTraceback("gofast.tools.coreutils.smart_strobj_recognition", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 1111, __pyx_L16_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2);
+1112: raise AttributeError(f"{name!r} attribute is not defined")
__Pyx_TraceLine(1112,0,__PYX_ERR(0, 1112, __pyx_L16_except_error)) __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1112, __pyx_L16_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_3, __pyx_kp_u_attribute_is_not_defined); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1112, __pyx_L16_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1112, __pyx_L16_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 1112, __pyx_L16_except_error) } goto __pyx_L16_except_error;
1113:
+1114: if deep and ix is None:
__Pyx_TraceLine(1114,0,__PYX_ERR(0, 1114, __pyx_L1_error)) __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_deep); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1114, __pyx_L1_error) if (__pyx_t_13) { } else { __pyx_t_5 = __pyx_t_13; goto __pyx_L23_bool_binop_done; } __pyx_t_13 = (__pyx_v_ix == Py_None); __pyx_t_5 = __pyx_t_13; __pyx_L23_bool_binop_done:; if (__pyx_t_5) { /* … */ }
1115: # go deeper in the search...
+1116: for ii, n in enumerate (container_) :
__Pyx_TraceLine(1116,0,__PYX_ERR(0, 1116, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_2 = __pyx_int_0; __pyx_t_1 = __pyx_v_container_; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1116, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_7); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 1116, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif __Pyx_XDECREF_SET(__pyx_v_n, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_2); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_7; __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(1116,0,__PYX_ERR(0, 1116, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L28_for_end; __pyx_L26_break:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L28_for_end; __pyx_L28_for_end:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1117: if n.find(name.lower())>=0 :
__Pyx_TraceLine(1117,0,__PYX_ERR(0, 1117, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_n, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_lower, __pyx_v_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_14 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_t_8}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_7, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1117, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { /* … */ }
+1118: ix =ii ; break
__Pyx_TraceLine(1118,0,__PYX_ERR(0, 1118, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_ii); __Pyx_DECREF_SET(__pyx_v_ix, __pyx_v_ii); goto __pyx_L26_break;
1119:
+1120: if ix is not None:
__Pyx_TraceLine(1120,0,__PYX_ERR(0, 1120, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_ix != Py_None); if (__pyx_t_5) { /* … */ }
+1121: if isinstance(container, dict):
__Pyx_TraceLine(1121,0,__PYX_ERR(0, 1121, __pyx_L1_error)) __pyx_t_5 = PyDict_Check(__pyx_v_container); if (__pyx_t_5) { /* … */ goto __pyx_L30; }
+1122: rv= list(container.keys())[ix]
__Pyx_TraceLine(1122,0,__PYX_ERR(0, 1122, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_container, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_ix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1122, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_2); __pyx_t_2 = 0;
+1123: else : rv= container[ix]
__Pyx_TraceLine(1123,0,__PYX_ERR(0, 1123, __pyx_L1_error)) /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_container, __pyx_v_ix); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_2); __pyx_t_2 = 0; } __pyx_L30:;
1124:
+1125: return rv
__Pyx_TraceLine(1125,0,__PYX_ERR(0, 1125, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_rv))||((__pyx_v_rv) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_rv))) __PYX_ERR(0, 1125, __pyx_L1_error) __Pyx_INCREF(__pyx_v_rv); __pyx_r = ((PyObject*)__pyx_v_rv); goto __pyx_L0;
1126:
+1127: def repr_callable_obj(obj: _F , skip = None ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_27repr_callable_obj(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_26repr_callable_obj, " Represent callable objects. \n \n Format class, function and instances objects. \n \n :param obj: class, func or instances\n object to format. \n :param skip: str , \n attribute name that is not end with '_' and whom it needs to be \n skipped. \n \n :Raises: TypeError - If object is not a callable or instanciated. \n \n :Examples: \n \n >>> from gofast.tools.coreutils import repr_callable_obj\n >>> from gofast.methods.electrical import ResistivityProfiling\n >>> repr_callable_obj(ResistivityProfiling)\n ... 'ResistivityProfiling(station= None, dipole= 10.0, \n auto_station= False, kws= None)'\n >>> robj= ResistivityProfiling (AB=200, MN=20, station ='S07')\n >>> repr_callable_obj(robj)\n ... 'ResistivityProfiling(AB= 200, MN= 20, arrangememt= schlumberger, ... ,\n dipole= 10.0, station= S07, auto= False)'\n >>> repr_callable_obj(robj.fit)\n ... 'fit(data= None, kws= None)'\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_27repr_callable_obj = {"repr_callable_obj", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_27repr_callable_obj, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_26repr_callable_obj}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_27repr_callable_obj(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_skip = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("repr_callable_obj (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_skip,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1127, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_skip); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1127, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "repr_callable_obj") < 0)) __PYX_ERR(0, 1127, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_obj = values[0]; __pyx_v_skip = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("repr_callable_obj", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 1127, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.repr_callable_obj", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_26repr_callable_obj(__pyx_self, __pyx_v_obj, __pyx_v_skip); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_26repr_callable_obj(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_skip) { PyObject *__pyx_v_regex = NULL; PyObject *__pyx_v_cls_or_func_signature = NULL; PyObject *__pyx_v_objname = NULL; PyObject *__pyx_v_PARAMS_VALUES = NULL; PyObject *__pyx_v_exs = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_f = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_8genexpr8__pyx_v_k = NULL; PyObject *__pyx_8genexpr8__pyx_v_v = NULL; PyObject *__pyx_8genexpr9__pyx_v_k = NULL; PyObject *__pyx_8genexpr9__pyx_v_v = NULL; PyObject *__pyx_9genexpr10__pyx_v_key = NULL; PyObject *__pyx_9genexpr11__pyx_v_key = NULL; PyObject *__pyx_9genexpr12__pyx_v_k = NULL; PyObject *__pyx_9genexpr13__pyx_v_k = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__51) __Pyx_TraceCall("repr_callable_obj", __pyx_f[0], 1127, 0, __PYX_ERR(0, 1127, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_skip); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils.repr_callable_obj", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_regex); __Pyx_XDECREF(__pyx_v_cls_or_func_signature); __Pyx_XDECREF(__pyx_v_objname); __Pyx_XDECREF(__pyx_v_PARAMS_VALUES); __Pyx_XDECREF(__pyx_v_exs); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_f); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_v); __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_k); __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_v); __Pyx_XDECREF(__pyx_9genexpr10__pyx_v_key); __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_key); __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_k); __Pyx_XDECREF(__pyx_9genexpr13__pyx_v_k); __Pyx_XDECREF(__pyx_v_skip); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__369 = PyTuple_Pack(18, __pyx_n_s_obj, __pyx_n_s_skip, __pyx_n_s_regex, __pyx_n_s_cls_or_func_signature, __pyx_n_s_objname, __pyx_n_s_PARAMS_VALUES, __pyx_n_s_exs, __pyx_n_s_d_3, __pyx_n_s_f, __pyx_n_s_e, __pyx_n_s_k, __pyx_n_s_v, __pyx_n_s_k, __pyx_n_s_v, __pyx_n_s_key, __pyx_n_s_key, __pyx_n_s_k, __pyx_n_s_k); if (unlikely(!__pyx_tuple__369)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__369); __Pyx_GIVEREF(__pyx_tuple__369); /* … */ __Pyx_TraceLine(1127,0,__PYX_ERR(0, 1127, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_obj, __pyx_n_s_F) < 0) __PYX_ERR(0, 1127, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_27repr_callable_obj, 0, __pyx_n_s_repr_callable_obj, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__51)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__62); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_repr_callable_obj, __pyx_t_2) < 0) __PYX_ERR(0, 1127, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__51 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__369, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_repr_callable_obj, 1127, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__51)) __PYX_ERR(0, 1127, __pyx_L1_error)
1128: """ Represent callable objects.
1129:
1130: Format class, function and instances objects.
1131:
1132: :param obj: class, func or instances
1133: object to format.
1134: :param skip: str ,
1135: attribute name that is not end with '_' and whom it needs to be
1136: skipped.
1137:
1138: :Raises: TypeError - If object is not a callable or instanciated.
1139:
1140: :Examples:
1141:
1142: >>> from gofast.tools.coreutils import repr_callable_obj
1143: >>> from gofast.methods.electrical import ResistivityProfiling
1144: >>> repr_callable_obj(ResistivityProfiling)
1145: ... 'ResistivityProfiling(station= None, dipole= 10.0,
1146: auto_station= False, kws= None)'
1147: >>> robj= ResistivityProfiling (AB=200, MN=20, station ='S07')
1148: >>> repr_callable_obj(robj)
1149: ... 'ResistivityProfiling(AB= 200, MN= 20, arrangememt= schlumberger, ... ,
1150: dipole= 10.0, station= S07, auto= False)'
1151: >>> repr_callable_obj(robj.fit)
1152: ... 'fit(data= None, kws= None)'
1153:
1154: """
+1155: regex = re.compile (r"[{'}]")
__Pyx_TraceLine(1155,0,__PYX_ERR(0, 1155, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_u__52}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_regex = __pyx_t_1; __pyx_t_1 = 0;
1156:
1157: # inspect.formatargspec(*inspect.getfullargspec(cls_or_func))
+1158: if not hasattr (obj, '__call__') and not hasattr(obj, '__dict__'):
__Pyx_TraceLine(1158,0,__PYX_ERR(0, 1158, __pyx_L1_error)) __pyx_t_6 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_call); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 1158, __pyx_L1_error) __pyx_t_7 = (!__pyx_t_6); if (__pyx_t_7) { } else { __pyx_t_5 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_dict); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1158, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_7); __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_5)) { /* … */ }
+1159: raise TypeError (
__Pyx_TraceLine(1159,0,__PYX_ERR(0, 1159, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 1159, __pyx_L1_error)
+1160: f'Format only callabe objects: Got {type (obj).__name__!r}')
__Pyx_TraceLine(1160,0,__PYX_ERR(0, 1160, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_1), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Format_only_callabe_objects_Got, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1161:
+1162: if hasattr (obj, '__call__'):
__Pyx_TraceLine(1162,0,__PYX_ERR(0, 1162, __pyx_L1_error)) __pyx_t_5 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_call); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1162, __pyx_L1_error) if (__pyx_t_5) { /* … */ goto __pyx_L6; }
+1163: cls_or_func_signature = inspect.signature(obj)
__Pyx_TraceLine(1163,0,__PYX_ERR(0, 1163, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_inspect); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_signature); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_obj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_cls_or_func_signature = __pyx_t_3; __pyx_t_3 = 0;
+1164: objname = obj.__name__
__Pyx_TraceLine(1164,0,__PYX_ERR(0, 1164, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_objname = __pyx_t_3; __pyx_t_3 = 0;
+1165: PARAMS_VALUES = {k: None if v.default is (inspect.Parameter.empty
__Pyx_TraceLine(1165,0,__PYX_ERR(0, 1165, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1165, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __Pyx_TraceLine(1165,0,__PYX_ERR(0, 1165, __pyx_L9_error)) __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr8__pyx_v_v, __pyx_n_s_default); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1165, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); /* … */ __Pyx_TraceLine(1166,0,__PYX_ERR(0, 1166, __pyx_L9_error)) __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_inspect); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1165, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_13); /* … */ __Pyx_TraceLine(1165,0,__PYX_ERR(0, 1165, __pyx_L9_error)) __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_Parameter); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1165, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_empty); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1165, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1165, __pyx_L9_error) if (!__pyx_t_5) { __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else { __Pyx_INCREF(__pyx_t_13); __pyx_t_12 = __pyx_t_13; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L12_bool_binop_done; } /* … */ __Pyx_TraceLine(1165,0,__PYX_ERR(0, 1165, __pyx_L9_error)) __Pyx_INCREF(Py_None); __pyx_t_1 = Py_None; } else {
+1166: or ...) else v.default
__Pyx_TraceLine(1166,0,__PYX_ERR(0, 1166, __pyx_L9_error)) __Pyx_INCREF(Py_Ellipsis); __pyx_t_12 = Py_Ellipsis; __pyx_L12_bool_binop_done:; __pyx_t_5 = (__pyx_t_10 == __pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_5) { /* … */ __Pyx_TraceLine(1166,0,__PYX_ERR(0, 1166, __pyx_L9_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr8__pyx_v_v, __pyx_n_s_default); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1166, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_1 = __pyx_t_12; __pyx_t_12 = 0; } if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_8genexpr8__pyx_v_k, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1165, __pyx_L9_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_k); __pyx_8genexpr8__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_v); __pyx_8genexpr8__pyx_v_v = 0; goto __pyx_L14_exit_scope; __pyx_L9_error:; __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_k); __pyx_8genexpr8__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr8__pyx_v_v); __pyx_8genexpr8__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L14_exit_scope:; } /* exit inner scope */ __pyx_v_PARAMS_VALUES = __pyx_t_3; __pyx_t_3 = 0;
+1167: for k, v in cls_or_func_signature.parameters.items()
__Pyx_TraceLine(1167,0,__PYX_ERR(0, 1167, __pyx_L9_error)) __pyx_t_8 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_cls_or_func_signature, __pyx_n_s_parameters); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1167, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1167, __pyx_L9_error) } __pyx_t_10 = __Pyx_dict_iterator(__pyx_t_1, 0, __pyx_n_s_items, (&__pyx_t_9), (&__pyx_t_4)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1167, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_10; __pyx_t_10 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_9, &__pyx_t_8, &__pyx_t_10, &__pyx_t_1, NULL, __pyx_t_4); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 1167, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_k, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr8__pyx_v_v, __pyx_t_1); __pyx_t_1 = 0;
1168: # if v.default is not inspect.Parameter.empty
1169: }
+1170: elif hasattr(obj, '__dict__'):
__Pyx_TraceLine(1170,0,__PYX_ERR(0, 1170, __pyx_L1_error)) __pyx_t_5 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1170, __pyx_L1_error) if (__pyx_t_5) { /* … */ } __pyx_L6:;
+1171: objname=obj.__class__.__name__
__Pyx_TraceLine(1171,0,__PYX_ERR(0, 1171, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_objname = __pyx_t_2; __pyx_t_2 = 0;
+1172: PARAMS_VALUES = {k:v for k, v in obj.__dict__.items()
__Pyx_TraceLine(1172,0,__PYX_ERR(0, 1172, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1172, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1172, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1172, __pyx_L17_error) } __pyx_t_12 = __Pyx_dict_iterator(__pyx_t_1, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_4)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1172, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_12; __pyx_t_12 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_8, &__pyx_t_9, &__pyx_t_12, &__pyx_t_1, NULL, __pyx_t_4); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 1172, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_8genexpr9__pyx_v_k, __pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF_SET(__pyx_8genexpr9__pyx_v_v, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1172,0,__PYX_ERR(0, 1172, __pyx_L17_error)) if (unlikely(PyDict_SetItem(__pyx_t_2, (PyObject*)__pyx_8genexpr9__pyx_v_k, (PyObject*)__pyx_8genexpr9__pyx_v_v))) __PYX_ERR(0, 1172, __pyx_L17_error)
+1173: if not ((k.endswith('_') or k.startswith('_')
__Pyx_TraceLine(1173,0,__PYX_ERR(0, 1173, __pyx_L17_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr9__pyx_v_k, __pyx_n_s_endswith); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1173, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_n_u__8}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1173, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1173, __pyx_L17_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L21_bool_binop_done; } /* … */ __Pyx_TraceLine(1175,0,__PYX_ERR(0, 1175, __pyx_L17_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr9__pyx_v_k, __pyx_n_s_startswith); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1173, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_n_u__8}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1173, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } /* … */ __Pyx_TraceLine(1173,0,__PYX_ERR(0, 1173, __pyx_L17_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1173, __pyx_L17_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L21_bool_binop_done; } /* … */ __Pyx_TraceLine(1173,0,__PYX_ERR(0, 1173, __pyx_L17_error)) __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_k); __pyx_8genexpr9__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_v); __pyx_8genexpr9__pyx_v_v = 0; goto __pyx_L25_exit_scope; __pyx_L17_error:; __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_k); __pyx_8genexpr9__pyx_v_k = 0; __Pyx_XDECREF(__pyx_8genexpr9__pyx_v_v); __pyx_8genexpr9__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L25_exit_scope:; } /* exit inner scope */ __pyx_v_PARAMS_VALUES = __pyx_t_2; __pyx_t_2 = 0;
1174: # remove the dict objects
+1175: or k.endswith('_kws') or k.endswith('_props'))
__Pyx_TraceLine(1175,0,__PYX_ERR(0, 1175, __pyx_L17_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr9__pyx_v_k, __pyx_n_s_endswith); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1175, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_n_u_kws}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1175, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1175, __pyx_L17_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L21_bool_binop_done; } __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr9__pyx_v_k, __pyx_n_s_endswith); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1175, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_n_u_props}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1175, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1175, __pyx_L17_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_6; __pyx_L21_bool_binop_done:;
1176: )
1177: }
+1178: if skip is not None :
__Pyx_TraceLine(1178,0,__PYX_ERR(0, 1178, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_skip != Py_None); if (__pyx_t_6) { /* … */ }
1179: # skip some inner params
1180: # remove them as the main function or class params
+1181: if isinstance(skip, (tuple, list, np.ndarray)):
__Pyx_TraceLine(1181,0,__PYX_ERR(0, 1181, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = PyTuple_Check(__pyx_v_skip); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L28_bool_binop_done; } __pyx_t_5 = PyList_Check(__pyx_v_skip); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L28_bool_binop_done; } __pyx_t_5 = PyObject_IsInstance(__pyx_v_skip, __pyx_t_3); __pyx_t_6 = __pyx_t_5; __pyx_L28_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ goto __pyx_L27; }
+1182: skip = list(map(str, skip ))
__Pyx_TraceLine(1182,0,__PYX_ERR(0, 1182, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF((PyObject *)(&PyUnicode_Type)); __Pyx_GIVEREF((PyObject *)(&PyUnicode_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 1182, __pyx_L1_error); __Pyx_INCREF(__pyx_v_skip); __Pyx_GIVEREF(__pyx_v_skip); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_skip)) __PYX_ERR(0, 1182, __pyx_L1_error); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_skip, __pyx_t_3); __pyx_t_3 = 0;
+1183: exs = [key for key in PARAMS_VALUES.keys() if key in skip]
__Pyx_TraceLine(1183,0,__PYX_ERR(0, 1183, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1183, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = 0; if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1183, __pyx_L33_error) } __pyx_t_1 = __Pyx_dict_iterator(__pyx_v_PARAMS_VALUES, 0, __pyx_n_s_keys, (&__pyx_t_9), (&__pyx_t_4)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1183, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_9, &__pyx_t_8, &__pyx_t_1, NULL, NULL, __pyx_t_4); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 1183, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_9genexpr10__pyx_v_key, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_9genexpr10__pyx_v_key, __pyx_v_skip, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1183, __pyx_L33_error) if (__pyx_t_6) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_9genexpr10__pyx_v_key))) __PYX_ERR(0, 1183, __pyx_L33_error) } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr10__pyx_v_key); __pyx_9genexpr10__pyx_v_key = 0; goto __pyx_L37_exit_scope; __pyx_L33_error:; __Pyx_XDECREF(__pyx_9genexpr10__pyx_v_key); __pyx_9genexpr10__pyx_v_key = 0; goto __pyx_L1_error; __pyx_L37_exit_scope:; } /* exit inner scope */ __pyx_v_exs = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
1184: else:
+1185: skip =str(skip).strip()
__Pyx_TraceLine(1185,0,__PYX_ERR(0, 1185, __pyx_L1_error)) /*else*/ { __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_skip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_skip, __pyx_t_3); __pyx_t_3 = 0;
+1186: exs = [key for key in PARAMS_VALUES.keys() if key.find(skip)>=0]
__Pyx_TraceLine(1186,0,__PYX_ERR(0, 1186, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = 0; if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1186, __pyx_L40_error) } __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_PARAMS_VALUES, 0, __pyx_n_s_keys, (&__pyx_t_8), (&__pyx_t_4)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_8, &__pyx_t_9, &__pyx_t_2, NULL, NULL, __pyx_t_4); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_9genexpr11__pyx_v_key, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr11__pyx_v_key, __pyx_n_s_find); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_skip}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1186, __pyx_L40_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_9genexpr11__pyx_v_key))) __PYX_ERR(0, 1186, __pyx_L40_error) } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_key); __pyx_9genexpr11__pyx_v_key = 0; goto __pyx_L44_exit_scope; __pyx_L40_error:; __Pyx_XDECREF(__pyx_9genexpr11__pyx_v_key); __pyx_9genexpr11__pyx_v_key = 0; goto __pyx_L1_error; __pyx_L44_exit_scope:; } /* exit inner scope */ __pyx_v_exs = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; } __pyx_L27:;
1187:
+1188: for d in exs:
__Pyx_TraceLine(1188,0,__PYX_ERR(0, 1188, __pyx_L1_error)) __pyx_t_3 = __pyx_v_exs; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1188, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1188, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1188, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1188,0,__PYX_ERR(0, 1188, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1189: PARAMS_VALUES.pop(d, None)
__Pyx_TraceLine(1189,0,__PYX_ERR(0, 1189, __pyx_L1_error)) if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1189, __pyx_L1_error) } __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_PARAMS_VALUES, __pyx_n_s_pop); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_d, Py_None}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1190:
1191: # use ellipsis as internal to stdout more than seven params items
+1192: if len(PARAMS_VALUES) >= 7 :
__Pyx_TraceLine(1192,0,__PYX_ERR(0, 1192, __pyx_L1_error)) if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1192, __pyx_L1_error) } __pyx_t_8 = PyObject_Length(__pyx_v_PARAMS_VALUES); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1192, __pyx_L1_error) __pyx_t_6 = (__pyx_t_8 >= 7); if (__pyx_t_6) { /* … */ }
+1193: f = {k:PARAMS_VALUES.get(k) for k in list(PARAMS_VALUES.keys())[:3]}
__Pyx_TraceLine(1193,0,__PYX_ERR(0, 1193, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1193, __pyx_L51_error) } __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_PARAMS_VALUES, __pyx_n_s_keys); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_t_12, 0, 3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __pyx_t_1; __Pyx_INCREF(__pyx_t_12); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1193, __pyx_L51_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1193, __pyx_L51_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_9genexpr12__pyx_v_k, __pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1193, __pyx_L51_error) } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_PARAMS_VALUES, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_9genexpr12__pyx_v_k}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_9genexpr12__pyx_v_k, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1193, __pyx_L51_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_k); __pyx_9genexpr12__pyx_v_k = 0; goto __pyx_L55_exit_scope; __pyx_L51_error:; __Pyx_XDECREF(__pyx_9genexpr12__pyx_v_k); __pyx_9genexpr12__pyx_v_k = 0; goto __pyx_L1_error; __pyx_L55_exit_scope:; } /* exit inner scope */ __pyx_v_f = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1194: e = {k:PARAMS_VALUES.get(k) for k in list(PARAMS_VALUES.keys())[-3:]}
__Pyx_TraceLine(1194,0,__PYX_ERR(0, 1194, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1194, __pyx_L58_error) } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_PARAMS_VALUES, __pyx_n_s_keys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PySequence_ListKeepNew(__pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyList_GetSlice(__pyx_t_1, -3L, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __pyx_t_12; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1194, __pyx_L58_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_12 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_12); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1194, __pyx_L58_error) #else __pyx_t_12 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_12); #endif __Pyx_XDECREF_SET(__pyx_9genexpr13__pyx_v_k, __pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1194, __pyx_L58_error) } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_PARAMS_VALUES, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_9genexpr13__pyx_v_k}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (unlikely(PyDict_SetItem(__pyx_t_3, (PyObject*)__pyx_9genexpr13__pyx_v_k, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 1194, __pyx_L58_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr13__pyx_v_k); __pyx_9genexpr13__pyx_v_k = 0; goto __pyx_L62_exit_scope; __pyx_L58_error:; __Pyx_XDECREF(__pyx_9genexpr13__pyx_v_k); __pyx_9genexpr13__pyx_v_k = 0; goto __pyx_L1_error; __pyx_L62_exit_scope:; } /* exit inner scope */ __pyx_v_e = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
1195:
+1196: PARAMS_VALUES= str(f) + ' ... ' + str(e )
__Pyx_TraceLine(1196,0,__PYX_ERR(0, 1196, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_f); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_u__40); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_e); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1196, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_PARAMS_VALUES, __pyx_t_12); __pyx_t_12 = 0;
1197:
+1198: return str(objname) + '(' + regex.sub('', str (PARAMS_VALUES)
__Pyx_TraceLine(1198,0,__PYX_ERR(0, 1198, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_objname)) { __Pyx_RaiseUnboundLocalError("objname"); __PYX_ERR(0, 1198, __pyx_L1_error) } __pyx_t_12 = __Pyx_PyObject_Str(__pyx_v_objname); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_3 = PyNumber_Add(__pyx_t_12, __pyx_kp_u__53); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_regex, __pyx_n_s_sub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(!__pyx_v_PARAMS_VALUES)) { __Pyx_RaiseUnboundLocalError("PARAMS_VALUES"); __PYX_ERR(0, 1198, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_PARAMS_VALUES); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_kp_u__22, __pyx_t_2}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* … */ __Pyx_TraceLine(1198,0,__PYX_ERR(0, 1198, __pyx_L1_error)) __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+1199: ).replace(':', '=') +')'
__Pyx_TraceLine(1199,0,__PYX_ERR(0, 1199, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_replace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1199,0,__PYX_ERR(0, 1199, __pyx_L1_error)) __pyx_t_12 = PyNumber_Add(__pyx_t_1, __pyx_kp_u__56); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0; /* … */ __pyx_tuple__55 = PyTuple_Pack(2, __pyx_kp_u__32, __pyx_kp_u__54); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 1199, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__55); __Pyx_GIVEREF(__pyx_tuple__55);
1200:
1201:
+1202: def accept_types (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_29accept_types(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_28accept_types, " List the type format that can be accepted by a function. \n \n :param objtypes: List of object types.\n :param format: bool - format the list of the name of objects.\n :return: list of object type names or str of object names. \n \n :Example: \n >>> import numpy as np; import pandas as pd \n >>> from gofast.tools.coreutils import accept_types\n >>> accept_types (pd.Series, pd.DataFrame, tuple, list, str)\n ... \"'Series','DataFrame','tuple','list' and 'str'\"\n >>> atypes= accept_types (\n pd.Series, pd.DataFrame,np.ndarray, format=True )\n ...\"'Series','DataFrame' and 'ndarray'\"\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_29accept_types = {"accept_types", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_29accept_types, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_28accept_types}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_29accept_types(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_format = 0; PyObject *__pyx_v_objtypes = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("accept_types (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_objtypes = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_format,0}; PyObject* values[1] = {0}; /* … */ /* function exit code */ __Pyx_DECREF(__pyx_v_objtypes); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_28accept_types(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_format, PyObject *__pyx_v_objtypes) { PyObject *__pyx_9genexpr14__pyx_v_o = NULL; PyObject *__pyx_9genexpr15__pyx_v_o = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__57) __Pyx_TraceCall("accept_types", __pyx_f[0], 1202, 0, __PYX_ERR(0, 1202, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.accept_types", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_9genexpr14__pyx_v_o); __Pyx_XDECREF(__pyx_9genexpr15__pyx_v_o); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__370 = PyTuple_Pack(4, __pyx_n_s_format, __pyx_n_s_objtypes, __pyx_n_s_o, __pyx_n_s_o); if (unlikely(!__pyx_tuple__370)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__370); __Pyx_GIVEREF(__pyx_tuple__370); /* … */ __Pyx_TraceLine(1202,0,__PYX_ERR(0, 1202, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_format, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 1202, __pyx_L1_error) __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_format, __pyx_n_s_bool) < 0) __PYX_ERR(0, 1202, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_objtypes, __pyx_n_s_list) < 0) __PYX_ERR(0, 1202, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_kp_s_Union_List_str_str) < 0) __PYX_ERR(0, 1202, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_29accept_types, 0, __pyx_n_s_accept_types, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__57)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_5, __pyx_t_2); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_accept_types, __pyx_t_5) < 0) __PYX_ERR(0, 1202, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__57 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__370, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_accept_types, 1202, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__57)) __PYX_ERR(0, 1202, __pyx_L1_error)
1203: *objtypes: list ,
+1204: format: bool = False
values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args == 1) { const Py_ssize_t index = 0; PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1202, __pyx_L3_error) } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "accept_types") < 0)) __PYX_ERR(0, 1202, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_format = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("accept_types", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 1202, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_objtypes); __pyx_v_objtypes = 0; __Pyx_AddTraceback("gofast.tools.coreutils.accept_types", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_28accept_types(__pyx_self, __pyx_v_format, __pyx_v_objtypes);
1205: ) -> Union [List[str] , str] :
1206: """ List the type format that can be accepted by a function.
1207:
1208: :param objtypes: List of object types.
1209: :param format: bool - format the list of the name of objects.
1210: :return: list of object type names or str of object names.
1211:
1212: :Example:
1213: >>> import numpy as np; import pandas as pd
1214: >>> from gofast.tools.coreutils import accept_types
1215: >>> accept_types (pd.Series, pd.DataFrame, tuple, list, str)
1216: ... "'Series','DataFrame','tuple','list' and 'str'"
1217: >>> atypes= accept_types (
1218: pd.Series, pd.DataFrame,np.ndarray, format=True )
1219: ..."'Series','DataFrame' and 'ndarray'"
1220: """
+1221: return smart_format(
__Pyx_TraceLine(1221,0,__PYX_ERR(0, 1221, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); /* … */ __Pyx_TraceLine(1221,0,__PYX_ERR(0, 1221, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); { /* enter inner scope */
+1222: [f'{o.__name__}' for o in objtypes]
__Pyx_TraceLine(1222,0,__PYX_ERR(0, 1222, __pyx_L5_error)) __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1222, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_v_objtypes; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1222, __pyx_L5_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_8); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1222, __pyx_L5_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1222, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_XDECREF_SET(__pyx_9genexpr14__pyx_v_o, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr14__pyx_v_o, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1222, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_8, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1222, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 1222, __pyx_L5_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_9genexpr14__pyx_v_o); __pyx_9genexpr14__pyx_v_o = 0; goto __pyx_L9_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_9genexpr14__pyx_v_o); __pyx_9genexpr14__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L9_exit_scope:; } /* exit inner scope */ __pyx_t_6 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_5}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { { /* enter inner scope */
+1223: ) if format else [f'{o.__name__}' for o in objtypes]
__Pyx_TraceLine(1223,0,__PYX_ERR(0, 1223, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_format); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1223, __pyx_L1_error) if (__pyx_t_2) { /* … */ __Pyx_TraceLine(1223,0,__PYX_ERR(0, 1223, __pyx_L12_error)) __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1223, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_v_objtypes; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1223, __pyx_L12_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1223, __pyx_L12_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1223, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_9genexpr15__pyx_v_o, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr15__pyx_v_o, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1223, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1223, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 1223, __pyx_L12_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_9genexpr15__pyx_v_o); __pyx_9genexpr15__pyx_v_o = 0; goto __pyx_L16_exit_scope; __pyx_L12_error:; __Pyx_XDECREF(__pyx_9genexpr15__pyx_v_o); __pyx_9genexpr15__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L16_exit_scope:; } /* exit inner scope */ __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1224:
+1225: def read_from_excelsheets(erp_file: str = None ) -> List[DataFrame]:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_31read_from_excelsheets(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_30read_from_excelsheets, " Read all Excelsheets and build a list of dataframe of all sheets.\n \n :param erp_file:\n Excell workbooks containing `erp` profile data.\n \n :return: A list composed of the name of `erp_file` at index =0 and the \n datataframes.\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_31read_from_excelsheets = {"read_from_excelsheets", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_31read_from_excelsheets, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_30read_from_excelsheets}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_31read_from_excelsheets(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_erp_file = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_from_excelsheets (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_erp_file,0}; PyObject* values[1] = {0}; values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_erp_file); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1225, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_from_excelsheets") < 0)) __PYX_ERR(0, 1225, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_erp_file = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("read_from_excelsheets", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 1225, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.read_from_excelsheets", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_erp_file), (&PyUnicode_Type), 1, "erp_file", 1))) __PYX_ERR(0, 1225, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_30read_from_excelsheets(__pyx_self, __pyx_v_erp_file); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_30read_from_excelsheets(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_erp_file) { PyObject *__pyx_v_allfls = NULL; PyObject *__pyx_v_list_of_df = NULL; CYTHON_UNUSED PyObject *__pyx_v_sheets = NULL; PyObject *__pyx_v_values = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__58) __Pyx_TraceCall("read_from_excelsheets", __pyx_f[0], 1225, 0, __PYX_ERR(0, 1225, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.read_from_excelsheets", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_allfls); __Pyx_XDECREF(__pyx_v_list_of_df); __Pyx_XDECREF(__pyx_v_sheets); __Pyx_XDECREF(__pyx_v_values); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__371 = PyTuple_Pack(5, __pyx_n_s_erp_file, __pyx_n_s_allfls, __pyx_n_s_list_of_df, __pyx_n_s_sheets, __pyx_n_s_values); if (unlikely(!__pyx_tuple__371)) __PYX_ERR(0, 1225, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__371); __Pyx_GIVEREF(__pyx_tuple__371); /* … */ __Pyx_TraceLine(1225,0,__PYX_ERR(0, 1225, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_erp_file, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1225, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_List_DataFrame) < 0) __PYX_ERR(0, 1225, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_31read_from_excelsheets, 0, __pyx_n_s_read_from_excelsheets, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1225, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__62); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_from_excelsheets, __pyx_t_4) < 0) __PYX_ERR(0, 1225, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__371, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_read_from_excelsheets, 1225, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 1225, __pyx_L1_error)
1226:
1227: """ Read all Excelsheets and build a list of dataframe of all sheets.
1228:
1229: :param erp_file:
1230: Excell workbooks containing `erp` profile data.
1231:
1232: :return: A list composed of the name of `erp_file` at index =0 and the
1233: datataframes.
1234:
1235: """
1236:
+1237: allfls:Dict [str, Dict [_T, List[_T]] ] = pd.read_excel(
__Pyx_TraceLine(1237,0,__PYX_ERR(0, 1237, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_read_excel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1238,0,__PYX_ERR(0, 1238, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_erp_file); __Pyx_GIVEREF(__pyx_v_erp_file); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_erp_file)) __PYX_ERR(0, 1237, __pyx_L1_error); /* … */ __Pyx_TraceLine(1237,0,__PYX_ERR(0, 1237, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_allfls = __pyx_t_4; __pyx_t_4 = 0;
+1238: erp_file, sheet_name=None)
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sheet_name, Py_None) < 0) __PYX_ERR(0, 1238, __pyx_L1_error)
1239:
+1240: list_of_df =[os.path.basename(os.path.splitext(erp_file)[0])]
__Pyx_TraceLine(1240,0,__PYX_ERR(0, 1240, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_splitext); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_erp_file}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_2}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_4)) __PYX_ERR(0, 1240, __pyx_L1_error); __pyx_t_4 = 0; __pyx_v_list_of_df = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1241: for sheets , values in allfls.items():
__Pyx_TraceLine(1241,0,__PYX_ERR(0, 1241, __pyx_L1_error)) __pyx_t_7 = 0; if (unlikely(__pyx_v_allfls == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1241, __pyx_L1_error) } __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_allfls, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_6)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_4; __pyx_t_4 = 0; while (1) { __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_8, &__pyx_t_7, &__pyx_t_4, &__pyx_t_2, NULL, __pyx_t_6); if (unlikely(__pyx_t_9 == 0)) break; if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 1241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_sheets, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_values, __pyx_t_2); __pyx_t_2 = 0;
+1242: list_of_df.append(pd.DataFrame(values))
__Pyx_TraceLine(1242,0,__PYX_ERR(0, 1242, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_values}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_list_of_df, __pyx_t_2); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1242, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1243:
+1244: return list_of_df
__Pyx_TraceLine(1244,0,__PYX_ERR(0, 1244, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_list_of_df); __pyx_r = __pyx_v_list_of_df; goto __pyx_L0;
1245:
+1246: def check_dimensionality(obj, data, z, x):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_33check_dimensionality(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_32check_dimensionality, " Check dimensionality of data and fix it.\n \n :param obj: Object, can be a class logged or else.\n :param data: 2D grid data of ndarray (z, x) dimensions.\n :param z: array-like should be reduced along the row axis.\n :param x: arraylike should be reduced along the columns axis.\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_33check_dimensionality = {"check_dimensionality", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_33check_dimensionality, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_32check_dimensionality}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_33check_dimensionality(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_data = 0; PyObject *__pyx_v_z = 0; PyObject *__pyx_v_x = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("check_dimensionality (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_data,&__pyx_n_s_z,&__pyx_n_s_x,0}; PyObject* values[4] = {0,0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1246, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1246, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("check_dimensionality", 1, 4, 4, 1); __PYX_ERR(0, 1246, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_z)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1246, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("check_dimensionality", 1, 4, 4, 2); __PYX_ERR(0, 1246, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[3]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1246, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("check_dimensionality", 1, 4, 4, 3); __PYX_ERR(0, 1246, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "check_dimensionality") < 0)) __PYX_ERR(0, 1246, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 4)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); } __pyx_v_obj = values[0]; __pyx_v_data = values[1]; __pyx_v_z = values[2]; __pyx_v_x = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("check_dimensionality", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 1246, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.check_dimensionality", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_32check_dimensionality(__pyx_self, __pyx_v_obj, __pyx_v_data, __pyx_v_z, __pyx_v_x); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_32check_dimensionality(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_data, PyObject *__pyx_v_z, PyObject *__pyx_v_x) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality *__pyx_cur_scope; PyObject *__pyx_v_reduce_shape = 0; PyObject *__pyx_v_sz0 = NULL; PyObject *__pyx_v_sx0 = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__59) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1246, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("check_dimensionality", __pyx_f[0], 1246, 0, __PYX_ERR(0, 1246, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_obj = __pyx_v_obj; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_obj); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_obj); __Pyx_INCREF(__pyx_v_data); __Pyx_INCREF(__pyx_v_z); __Pyx_INCREF(__pyx_v_x); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.check_dimensionality", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_reduce_shape); __Pyx_XDECREF(__pyx_v_sz0); __Pyx_XDECREF(__pyx_v_sx0); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_z); __Pyx_XDECREF(__pyx_v_x); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__372 = PyTuple_Pack(8, __pyx_n_s_obj, __pyx_n_s_data, __pyx_n_s_z, __pyx_n_s_x, __pyx_n_s_reduce_shape, __pyx_n_s_reduce_shape, __pyx_n_s_sz0, __pyx_n_s_sx0); if (unlikely(!__pyx_tuple__372)) __PYX_ERR(0, 1246, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__372); __Pyx_GIVEREF(__pyx_tuple__372); /* … */ __Pyx_TraceLine(1246,0,__PYX_ERR(0, 1246, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_33check_dimensionality, 0, __pyx_n_s_check_dimensionality, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_dimensionality, __pyx_t_4) < 0) __PYX_ERR(0, 1246, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__372, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_check_dimensionality, 1246, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 1246, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality { PyObject_HEAD PyObject *__pyx_v_obj; };
1247: """ Check dimensionality of data and fix it.
1248:
1249: :param obj: Object, can be a class logged or else.
1250: :param data: 2D grid data of ndarray (z, x) dimensions.
1251: :param z: array-like should be reduced along the row axis.
1252: :param x: arraylike should be reduced along the columns axis.
1253:
1254: """
+1255: def reduce_shape(Xshape, x, axis_name=None):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_20check_dimensionality_1reduce_shape(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_20check_dimensionality_reduce_shape, " Reduce shape to keep the same shape"); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_20check_dimensionality_1reduce_shape = {"reduce_shape", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_20check_dimensionality_1reduce_shape, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_20check_dimensionality_reduce_shape}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_20check_dimensionality_1reduce_shape(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_Xshape = 0; PyObject *__pyx_v_x = 0; PyObject *__pyx_v_axis_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reduce_shape (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_Xshape,&__pyx_n_s_x,&__pyx_n_s_axis_name,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_Xshape)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1255, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1255, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("reduce_shape", 0, 2, 3, 1); __PYX_ERR(0, 1255, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_axis_name); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1255, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "reduce_shape") < 0)) __PYX_ERR(0, 1255, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_Xshape = values[0]; __pyx_v_x = values[1]; __pyx_v_axis_name = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("reduce_shape", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 1255, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.check_dimensionality.reduce_shape", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_20check_dimensionality_reduce_shape(__pyx_self, __pyx_v_Xshape, __pyx_v_x, __pyx_v_axis_name); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_20check_dimensionality_reduce_shape(PyObject *__pyx_self, PyObject *__pyx_v_Xshape, PyObject *__pyx_v_x, PyObject *__pyx_v_axis_name) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality *__pyx_cur_scope; struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality *__pyx_outer_scope; PyObject *__pyx_v_mess = NULL; Py_ssize_t __pyx_v_ox; PyObject *__pyx_v_dsh = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_3_check_dimensionality *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_TraceCall("reduce_shape", __pyx_f[0], 1255, 0, __PYX_ERR(0, 1255, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_Xshape); __Pyx_INCREF(__pyx_v_x); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils.check_dimensionality.reduce_shape", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_mess); __Pyx_XDECREF(__pyx_v_dsh); __Pyx_XDECREF(__pyx_v_Xshape); __Pyx_XDECREF(__pyx_v_x); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__60 = PyTuple_Pack(6, __pyx_n_s_Xshape, __pyx_n_s_x, __pyx_n_s_axis_name, __pyx_n_s_mess, __pyx_n_s_ox, __pyx_n_s_dsh); if (unlikely(!__pyx_tuple__60)) __PYX_ERR(0, 1255, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__60); __Pyx_GIVEREF(__pyx_tuple__60); __pyx_codeobj__61 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_reduce_shape, 1255, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__61)) __PYX_ERR(0, 1255, __pyx_L1_error) /* … */ __Pyx_TraceLine(1255,0,__PYX_ERR(0, 1255, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_20check_dimensionality_1reduce_shape, 0, __pyx_n_s_check_dimensionality_locals_redu, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__61)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__62); __pyx_v_reduce_shape = __pyx_t_1; __pyx_t_1 = 0; __pyx_tuple__62 = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_tuple__62)) __PYX_ERR(0, 1255, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__62); __Pyx_GIVEREF(__pyx_tuple__62);
1256: """ Reduce shape to keep the same shape"""
+1257: mess ="`{0}` shape({1}) {2} than the data shape `{0}` = ({3})."
__Pyx_TraceLine(1257,0,__PYX_ERR(0, 1257, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_0_shape_1_2_than_the_data_shape); __pyx_v_mess = __pyx_kp_u_0_shape_1_2_than_the_data_shape;
+1258: ox = len(x)
__Pyx_TraceLine(1258,0,__PYX_ERR(0, 1258, __pyx_L1_error)) __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1258, __pyx_L1_error) __pyx_v_ox = __pyx_t_1;
+1259: dsh = Xshape
__Pyx_TraceLine(1259,0,__PYX_ERR(0, 1259, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_Xshape); __pyx_v_dsh = __pyx_v_Xshape;
+1260: if len(x) > Xshape :
__Pyx_TraceLine(1260,0,__PYX_ERR(0, 1260, __pyx_L1_error)) __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1260, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_v_Xshape, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1260, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1260, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { /* … */ goto __pyx_L3; }
+1261: x = x[: int (Xshape)]
__Pyx_TraceLine(1261,0,__PYX_ERR(0, 1261, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_Xshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_x, 0, 0, NULL, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_2); __pyx_t_2 = 0;
+1262: obj._logging.debug(''.join([
__Pyx_TraceLine(1262,0,__PYX_ERR(0, 1262, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_obj)) { __Pyx_RaiseClosureNameError("obj"); __PYX_ERR(0, 1262, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_obj, __pyx_n_s_logging); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(1262,0,__PYX_ERR(0, 1262, __pyx_L1_error)) __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_7)) __PYX_ERR(0, 1262, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_3)) __PYX_ERR(0, 1262, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_3 = 0; __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1263: f"Resize {axis_name!r}={ox!r} to {Xshape!r}.",
__Pyx_TraceLine(1263,0,__PYX_ERR(0, 1263, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u_Resize); __pyx_t_1 += 7; __Pyx_GIVEREF(__pyx_kp_u_Resize); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Resize); __pyx_t_7 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_axis_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_6; __pyx_t_1 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u__54); __pyx_t_1 += 1; __Pyx_GIVEREF(__pyx_kp_u__54); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__54); __pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_ox, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_to); __pyx_t_1 += 4; __Pyx_GIVEREF(__pyx_kp_u_to); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u_to); __pyx_t_7 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_Xshape), __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_6; __pyx_t_1 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_1 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_kp_u__26); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_3, 7, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1263, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1264: mess.format(axis_name, len(x),'more',Xshape)]))
__Pyx_TraceLine(1264,0,__PYX_ERR(0, 1264, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_mess, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1264, __pyx_L1_error) __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_10, __pyx_v_axis_name, __pyx_t_9, __pyx_n_u_more, __pyx_v_Xshape}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_11, 4+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
1265:
+1266: elif len(x) < Xshape:
__Pyx_TraceLine(1266,0,__PYX_ERR(0, 1266, __pyx_L1_error)) __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1266, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_v_Xshape, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_4) { /* … */ } __pyx_L3:;
+1267: Xshape = len(x)
__Pyx_TraceLine(1267,0,__PYX_ERR(0, 1267, __pyx_L1_error)) __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1267, __pyx_L1_error) __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF_SET(__pyx_v_Xshape, __pyx_t_5); __pyx_t_5 = 0;
+1268: obj._logging.debug(''.join([
__Pyx_TraceLine(1268,0,__PYX_ERR(0, 1268, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_obj)) { __Pyx_RaiseClosureNameError("obj"); __PYX_ERR(0, 1268, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_obj, __pyx_n_s_logging); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(1268,0,__PYX_ERR(0, 1268, __pyx_L1_error)) __pyx_t_7 = PyList_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_8)) __PYX_ERR(0, 1268, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_2)) __PYX_ERR(0, 1268, __pyx_L1_error); __pyx_t_8 = 0; __pyx_t_2 = 0; __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_2}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1269: f"Resize {axis_name!r}={dsh!r} to {Xshape!r}.",
__Pyx_TraceLine(1269,0,__PYX_ERR(0, 1269, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u_Resize); __pyx_t_1 += 7; __Pyx_GIVEREF(__pyx_kp_u_Resize); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_Resize); __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_axis_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6; __pyx_t_1 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__54); __pyx_t_1 += 1; __Pyx_GIVEREF(__pyx_kp_u__54); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__54); __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_dsh), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6; __pyx_t_1 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u_to); __pyx_t_1 += 4; __Pyx_GIVEREF(__pyx_kp_u_to); PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_kp_u_to); __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_Xshape), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6; __pyx_t_1 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_1 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_kp_u__26); __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_2, 7, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1270: mess.format(axis_name, len(x),'less', Xshape)]))
__Pyx_TraceLine(1270,0,__PYX_ERR(0, 1270, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_mess, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1270, __pyx_L1_error) __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; __pyx_t_11 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_11 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_10, __pyx_v_axis_name, __pyx_t_9, __pyx_n_u_less, __pyx_v_Xshape}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_11, 4+__pyx_t_11); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; }
+1271: return int(Xshape), x
__Pyx_TraceLine(1271,0,__PYX_ERR(0, 1271, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_v_Xshape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5)) __PYX_ERR(0, 1271, __pyx_L1_error); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_x)) __PYX_ERR(0, 1271, __pyx_L1_error); __pyx_t_5 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1272:
+1273: sz0, z = reduce_shape(data.shape[0],
__Pyx_TraceLine(1273,0,__PYX_ERR(0, 1273, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2)) __PYX_ERR(0, 1273, __pyx_L1_error); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(1273,0,__PYX_ERR(0, 1273, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_reduce_shape, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1273, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1273, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1273, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1273, __pyx_L1_error) __pyx_L4_unpacking_done:; } __pyx_v_sz0 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_z, __pyx_t_1); __pyx_t_1 = 0;
+1274: x=z, axis_name ='Z')
__Pyx_TraceLine(1274,0,__PYX_ERR(0, 1274, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_x, __pyx_v_z) < 0) __PYX_ERR(0, 1274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis_name, __pyx_n_u_Z) < 0) __PYX_ERR(0, 1274, __pyx_L1_error)
+1275: sx0, x =reduce_shape (data.shape[1],
__Pyx_TraceLine(1275,0,__PYX_ERR(0, 1275, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 1275, __pyx_L1_error); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1275,0,__PYX_ERR(0, 1275, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_reduce_shape, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1275, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); index = 0; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) __PYX_ERR(0, 1275, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1275, __pyx_L1_error) __pyx_L6_unpacking_done:; } __pyx_v_sx0 = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_3); __pyx_t_3 = 0;
+1276: x=x, axis_name ='X')
__Pyx_TraceLine(1276,0,__PYX_ERR(0, 1276, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1276, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_x, __pyx_v_x) < 0) __PYX_ERR(0, 1276, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_axis_name, __pyx_n_u_X) < 0) __PYX_ERR(0, 1276, __pyx_L1_error)
+1277: data = data [:sz0, :sx0]
__Pyx_TraceLine(1277,0,__PYX_ERR(0, 1277, __pyx_L1_error)) __pyx_t_2 = PySlice_New(Py_None, __pyx_v_sz0, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySlice_New(Py_None, __pyx_v_sx0, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2)) __PYX_ERR(0, 1277, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3)) __PYX_ERR(0, 1277, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1277, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
1278:
+1279: return data , z, x
__Pyx_TraceLine(1279,0,__PYX_ERR(0, 1279, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data)) __PYX_ERR(0, 1279, __pyx_L1_error); __Pyx_INCREF(__pyx_v_z); __Pyx_GIVEREF(__pyx_v_z); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_z)) __PYX_ERR(0, 1279, __pyx_L1_error); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_x)) __PYX_ERR(0, 1279, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
1280:
+1281: def smart_format(iter_obj, choice ='and'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_35smart_format(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_34smart_format, " Smart format iterable object.\n \n :param iter_obj: iterable obj \n :param choice: can be 'and' or 'or' for optional.\n \n :Example: \n >>> from gofast.tools.coreutils import smart_format\n >>> smart_format(['model', 'iter', 'mesh', 'data'])\n ... 'model','iter','mesh' and 'data'\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_35smart_format = {"smart_format", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_35smart_format, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_34smart_format}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_35smart_format(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_iter_obj = 0; PyObject *__pyx_v_choice = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("smart_format (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_iter_obj,&__pyx_n_s_choice,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_and))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_iter_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1281, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_choice); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1281, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "smart_format") < 0)) __PYX_ERR(0, 1281, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_iter_obj = values[0]; __pyx_v_choice = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("smart_format", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 1281, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.smart_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_34smart_format(__pyx_self, __pyx_v_iter_obj, __pyx_v_choice); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_34smart_format(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_iter_obj, PyObject *__pyx_v_choice) { PyObject *__pyx_v_str_litteral = NULL; PyObject *__pyx_9genexpr16__pyx_v_obj = NULL; PyObject *__pyx_9genexpr17__pyx_v_i = NULL; PyObject *__pyx_9genexpr18__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__63) __Pyx_TraceCall("smart_format", __pyx_f[0], 1281, 0, __PYX_ERR(0, 1281, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_iter_obj); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.smart_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_str_litteral); __Pyx_XDECREF(__pyx_9genexpr16__pyx_v_obj); __Pyx_XDECREF(__pyx_9genexpr17__pyx_v_i); __Pyx_XDECREF(__pyx_9genexpr18__pyx_v_i); __Pyx_XDECREF(__pyx_v_iter_obj); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__373 = PyTuple_Pack(6, __pyx_n_s_iter_obj, __pyx_n_s_choice, __pyx_n_s_str_litteral, __pyx_n_s_obj, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__373)) __PYX_ERR(0, 1281, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__373); __Pyx_GIVEREF(__pyx_tuple__373); __pyx_codeobj__63 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__373, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_smart_format, 1281, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__63)) __PYX_ERR(0, 1281, __pyx_L1_error) /* … */ __Pyx_TraceLine(1281,0,__PYX_ERR(0, 1281, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_35smart_format, 0, __pyx_n_s_smart_format, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__63)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__374); if (PyDict_SetItem(__pyx_d, __pyx_n_s_smart_format, __pyx_t_4) < 0) __PYX_ERR(0, 1281, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__374 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_and)); if (unlikely(!__pyx_tuple__374)) __PYX_ERR(0, 1281, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__374); __Pyx_GIVEREF(__pyx_tuple__374);
1282: """ Smart format iterable object.
1283:
1284: :param iter_obj: iterable obj
1285: :param choice: can be 'and' or 'or' for optional.
1286:
1287: :Example:
1288: >>> from gofast.tools.coreutils import smart_format
1289: >>> smart_format(['model', 'iter', 'mesh', 'data'])
1290: ... 'model','iter','mesh' and 'data'
1291: """
+1292: str_litteral =''
__Pyx_TraceLine(1292,0,__PYX_ERR(0, 1292, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__22); __pyx_v_str_litteral = __pyx_kp_u__22;
+1293: try:
__Pyx_TraceLine(1293,0,__PYX_ERR(0, 1293, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L8_try_end:; }
+1294: iter(iter_obj)
__Pyx_TraceLine(1294,0,__PYX_ERR(0, 1294, __pyx_L3_error)) __pyx_t_4 = PyObject_GetIter(__pyx_v_iter_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1294, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1295: except: return f"{iter_obj}"
__Pyx_TraceLine(1295,0,__PYX_ERR(0, 1295, __pyx_L5_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.smart_format", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 1295, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_iter_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1295, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_r = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; }
1296:
+1297: iter_obj = [str(obj) for obj in iter_obj]
__Pyx_TraceLine(1297,0,__PYX_ERR(0, 1297, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1297, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); if (likely(PyList_CheckExact(__pyx_v_iter_obj)) || PyTuple_CheckExact(__pyx_v_iter_obj)) { __pyx_t_5 = __pyx_v_iter_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_iter_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1297, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1297, __pyx_L13_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_5))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1297, __pyx_L13_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1297, __pyx_L13_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1297, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1297, __pyx_L13_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1297, __pyx_L13_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1297, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1297, __pyx_L13_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_9genexpr16__pyx_v_obj, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Str(__pyx_9genexpr16__pyx_v_obj); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1297, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 1297, __pyx_L13_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_9genexpr16__pyx_v_obj); __pyx_9genexpr16__pyx_v_obj = 0; goto __pyx_L17_exit_scope; __pyx_L13_error:; __Pyx_XDECREF(__pyx_9genexpr16__pyx_v_obj); __pyx_9genexpr16__pyx_v_obj = 0; goto __pyx_L1_error; __pyx_L17_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_iter_obj, __pyx_t_6); __pyx_t_6 = 0;
+1298: if len(iter_obj) ==1:
__Pyx_TraceLine(1298,0,__PYX_ERR(0, 1298, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_iter_obj); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1298, __pyx_L1_error) __pyx_t_10 = (__pyx_t_8 == 1); if (__pyx_t_10) { /* … */ goto __pyx_L18; }
+1299: str_litteral= ','.join([f"{i!r}" for i in iter_obj ])
__Pyx_TraceLine(1299,0,__PYX_ERR(0, 1299, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1299, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_6); if (likely(PyList_CheckExact(__pyx_v_iter_obj)) || PyTuple_CheckExact(__pyx_v_iter_obj)) { __pyx_t_5 = __pyx_v_iter_obj; __Pyx_INCREF(__pyx_t_5); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_iter_obj); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1299, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1299, __pyx_L21_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_5))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1299, __pyx_L21_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1299, __pyx_L21_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1299, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1299, __pyx_L21_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1299, __pyx_L21_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1299, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_9(__pyx_t_5); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1299, __pyx_L21_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_9genexpr17__pyx_v_i, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_9genexpr17__pyx_v_i), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1299, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 1299, __pyx_L21_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_9genexpr17__pyx_v_i); __pyx_9genexpr17__pyx_v_i = 0; goto __pyx_L25_exit_scope; __pyx_L21_error:; __Pyx_XDECREF(__pyx_9genexpr17__pyx_v_i); __pyx_9genexpr17__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L25_exit_scope:; } /* exit inner scope */ __pyx_t_5 = PyUnicode_Join(__pyx_kp_u__48, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_str_litteral, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
+1300: elif len(iter_obj)>1:
__Pyx_TraceLine(1300,0,__PYX_ERR(0, 1300, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_iter_obj); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1300, __pyx_L1_error) __pyx_t_10 = (__pyx_t_8 > 1); if (__pyx_t_10) { /* … */ } __pyx_L18:;
+1301: str_litteral = ','.join([f"{i!r}" for i in iter_obj[:-1]])
__Pyx_TraceLine(1301,0,__PYX_ERR(0, 1301, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_iter_obj, 0, -1L, NULL, NULL, &__pyx_slice__64, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_6); if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_4 = __pyx_t_6; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1301, __pyx_L28_error) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1301, __pyx_L28_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1301, __pyx_L28_error) #else __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_6); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1301, __pyx_L28_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1301, __pyx_L28_error) #else __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_6); #endif } } else { __pyx_t_6 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_6)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1301, __pyx_L28_error) } break; } __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF_SET(__pyx_9genexpr18__pyx_v_i, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_9genexpr18__pyx_v_i), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 1301, __pyx_L28_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_9genexpr18__pyx_v_i); __pyx_9genexpr18__pyx_v_i = 0; goto __pyx_L32_exit_scope; __pyx_L28_error:; __Pyx_XDECREF(__pyx_9genexpr18__pyx_v_i); __pyx_9genexpr18__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L32_exit_scope:; } /* exit inner scope */ __pyx_t_4 = PyUnicode_Join(__pyx_kp_u__48, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_str_litteral, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* … */ __pyx_slice__64 = PySlice_New(Py_None, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice__64)) __PYX_ERR(0, 1301, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__64); __Pyx_GIVEREF(__pyx_slice__64);
+1302: str_litteral += f" {choice} {iter_obj[-1]!r}"
__Pyx_TraceLine(1302,0,__PYX_ERR(0, 1302, __pyx_L1_error)) __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_u__14); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_choice, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_11; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_kp_u__14); __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_iter_obj, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_11; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_4, 4, __pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyUnicode_ConcatInPlaceSafe(__pyx_v_str_litteral, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_str_litteral, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+1303: return str_litteral
__Pyx_TraceLine(1303,0,__PYX_ERR(0, 1303, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_str_litteral); __pyx_r = __pyx_v_str_litteral; goto __pyx_L0;
1304:
+1305: def make_introspection(Obj: object , subObj: _Sub[object])->None:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_37make_introspection(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_36make_introspection, " Make introspection by using the attributes of instance created to \n populate the new classes created.\n \n :param Obj: callable \n New object to fully inherits of `subObject` attributes.\n \n :param subObj: Callable \n Instance created.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_37make_introspection = {"make_introspection", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_37make_introspection, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_36make_introspection}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_37make_introspection(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_Obj = 0; PyObject *__pyx_v_subObj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_introspection (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_Obj,&__pyx_n_s_subObj,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_Obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1305, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_subObj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1305, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("make_introspection", 1, 2, 2, 1); __PYX_ERR(0, 1305, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "make_introspection") < 0)) __PYX_ERR(0, 1305, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_Obj = values[0]; __pyx_v_subObj = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("make_introspection", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1305, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.make_introspection", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_36make_introspection(__pyx_self, __pyx_v_Obj, __pyx_v_subObj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_36make_introspection(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_Obj, PyObject *__pyx_v_subObj) { PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__65) __Pyx_TraceCall("make_introspection", __pyx_f[0], 1305, 0, __PYX_ERR(0, 1305, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.make_introspection", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__375 = PyTuple_Pack(4, __pyx_n_s_Obj, __pyx_n_s_subObj, __pyx_n_s_key, __pyx_n_s_value); if (unlikely(!__pyx_tuple__375)) __PYX_ERR(0, 1305, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__375); __Pyx_GIVEREF(__pyx_tuple__375); /* … */ __Pyx_TraceLine(1305,0,__PYX_ERR(0, 1305, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_Obj, __pyx_n_s_object) < 0) __PYX_ERR(0, 1305, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_subObj, __pyx_kp_s_Sub_object) < 0) __PYX_ERR(0, 1305, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_None) < 0) __PYX_ERR(0, 1305, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_37make_introspection, 0, __pyx_n_s_make_introspection, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__65)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_introspection, __pyx_t_5) < 0) __PYX_ERR(0, 1305, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__65 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__375, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_make_introspection, 1305, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__65)) __PYX_ERR(0, 1305, __pyx_L1_error)
1306: """ Make introspection by using the attributes of instance created to
1307: populate the new classes created.
1308:
1309: :param Obj: callable
1310: New object to fully inherits of `subObject` attributes.
1311:
1312: :param subObj: Callable
1313: Instance created.
1314: """
1315: # make introspection and set the all attributes to self object.
1316: # if Obj attribute has the same name with subObj attribute, then
1317: # Obj attributes get the priority.
+1318: for key, value in subObj.__dict__.items():
__Pyx_TraceLine(1318,0,__PYX_ERR(0, 1318, __pyx_L1_error)) __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_subObj, __pyx_n_s_dict); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__pyx_t_5 == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 1318, __pyx_L1_error) } __pyx_t_6 = __Pyx_dict_iterator(__pyx_t_5, 0, __pyx_n_s_items, (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; while (1) { __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_3, &__pyx_t_2, &__pyx_t_6, &__pyx_t_5, NULL, __pyx_t_4); if (unlikely(__pyx_t_7 == 0)) break; if (unlikely(__pyx_t_7 == -1)) __PYX_ERR(0, 1318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5); __pyx_t_5 = 0;
+1319: if not hasattr(Obj, key) and key != ''.join(['__', str(key), '__']):
__Pyx_TraceLine(1319,0,__PYX_ERR(0, 1319, __pyx_L1_error)) __pyx_t_9 = __Pyx_HasAttr(__pyx_v_Obj, __pyx_v_key); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1319, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_9); if (__pyx_t_10) { } else { __pyx_t_8 = __pyx_t_10; goto __pyx_L6_bool_binop_done; } __pyx_t_5 = __Pyx_PyObject_Str(__pyx_v_key); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_n_u__66); __Pyx_GIVEREF(__pyx_n_u__66); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u__66)) __PYX_ERR(0, 1319, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_5)) __PYX_ERR(0, 1319, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u__66); __Pyx_GIVEREF(__pyx_n_u__66); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 2, __pyx_n_u__66)) __PYX_ERR(0, 1319, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_v_key, __pyx_t_5, Py_NE)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1319, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __pyx_t_10; __pyx_L6_bool_binop_done:; if (__pyx_t_8) { /* … */ } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1320: setattr(Obj, key, value)
__Pyx_TraceLine(1320,0,__PYX_ERR(0, 1320, __pyx_L1_error)) __pyx_t_11 = PyObject_SetAttr(__pyx_v_Obj, __pyx_v_key, __pyx_v_value); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 1320, __pyx_L1_error)
1321:
+1322: def cpath(savepath: str = None, dpath: str = '_default_path_') -> str:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_39cpath(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_38cpath, "\n Ensure a directory exists for saving files. If the specified savepath \n does not exist, it will be created. If no savepath is specified, a default\n directory is used.\n\n Parameters:\n - savepath (str, optional): The target directory to validate or create. \n If None, dpath is used.\n - dpath (str): The default directory to use if savepath is None. Created \n in the current working directory.\n\n Returns:\n - str: The absolute path to the validated or created directory.\n\n Example:\n ```\n # Using the default path\n default_path = cpath()\n print(f\"Files will be saved to: {default_path}\")\n\n # Specifying a custom path\n custom_path = cpath('/path/to/save')\n print(f\"Files will be saved to: {custom_path}\")\n ```\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_39cpath = {"cpath", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_39cpath, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_38cpath}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_39cpath(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_savepath = 0; PyObject *__pyx_v_dpath = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cpath (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_savepath,&__pyx_n_s_dpath,0}; PyObject* values[2] = {0,0}; values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_default_path))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1322, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dpath); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1322, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "cpath") < 0)) __PYX_ERR(0, 1322, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_savepath = ((PyObject*)values[0]); __pyx_v_dpath = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cpath", 0, 0, 2, __pyx_nargs); __PYX_ERR(0, 1322, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.cpath", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_savepath), (&PyUnicode_Type), 1, "savepath", 1))) __PYX_ERR(0, 1322, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dpath), (&PyUnicode_Type), 0, "dpath", 1))) __PYX_ERR(0, 1322, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_38cpath(__pyx_self, __pyx_v_savepath, __pyx_v_dpath); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_38cpath(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_savepath, PyObject *__pyx_v_dpath) { PyObject *__pyx_v_Path = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__67) __Pyx_TraceCall("cpath", __pyx_f[0], 1322, 0, __PYX_ERR(0, 1322, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_savepath); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.cpath", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_Path); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_savepath); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__376 = PyTuple_Pack(4, __pyx_n_s_savepath, __pyx_n_s_dpath, __pyx_n_s_Path, __pyx_n_s_e); if (unlikely(!__pyx_tuple__376)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__376); __Pyx_GIVEREF(__pyx_tuple__376); __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__376, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_cpath, 1322, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 1322, __pyx_L1_error) /* … */ __Pyx_TraceLine(1322,0,__PYX_ERR(0, 1322, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_savepath, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1322, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dpath, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1322, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1322, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_39cpath, 0, __pyx_n_s_cpath, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__377); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_cpath, __pyx_t_4) < 0) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__377 = PyTuple_Pack(2, Py_None, ((PyObject*)__pyx_n_u_default_path)); if (unlikely(!__pyx_tuple__377)) __PYX_ERR(0, 1322, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__377); __Pyx_GIVEREF(__pyx_tuple__377);
1323: """
1324: Ensure a directory exists for saving files. If the specified savepath
1325: does not exist, it will be created. If no savepath is specified, a default
1326: directory is used.
1327:
1328: Parameters:
1329: - savepath (str, optional): The target directory to validate or create.
1330: If None, dpath is used.
1331: - dpath (str): The default directory to use if savepath is None. Created
1332: in the current working directory.
1333:
1334: Returns:
1335: - str: The absolute path to the validated or created directory.
1336:
1337: Example:
1338: ```
1339: # Using the default path
1340: default_path = cpath()
1341: print(f"Files will be saved to: {default_path}")
1342:
1343: # Specifying a custom path
1344: custom_path = cpath('/path/to/save')
1345: print(f"Files will be saved to: {custom_path}")
1346: ```
1347: """
+1348: from pathlib import Path
__Pyx_TraceLine(1348,0,__PYX_ERR(0, 1348, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_Path); __Pyx_GIVEREF(__pyx_n_s_Path); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Path)) __PYX_ERR(0, 1348, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_pathlib, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v_Path = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1349: if savepath is None:
__Pyx_TraceLine(1349,0,__PYX_ERR(0, 1349, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_savepath == ((PyObject*)Py_None)); if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+1350: savepath = Path.cwd() / dpath
__Pyx_TraceLine(1350,0,__PYX_ERR(0, 1350, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Path, __pyx_n_s_cwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_v_dpath); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1350, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_savepath, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
1351: else:
+1352: savepath = Path(savepath)
__Pyx_TraceLine(1352,0,__PYX_ERR(0, 1352, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_v_Path); __pyx_t_2 = __pyx_v_Path; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_savepath}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1352, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_savepath, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; } __pyx_L3:;
1353:
+1354: try:
__Pyx_TraceLine(1354,0,__PYX_ERR(0, 1354, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L5_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L9_try_end:; }
+1355: savepath.mkdir(parents=True, exist_ok=True)
__Pyx_TraceLine(1355,0,__PYX_ERR(0, 1355, __pyx_L4_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_savepath, __pyx_n_s_mkdir); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1355, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1355, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parents, Py_True) < 0) __PYX_ERR(0, 1355, __pyx_L4_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exist_ok, Py_True) < 0) __PYX_ERR(0, 1355, __pyx_L4_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1355, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1356: except Exception as e:
__Pyx_TraceLine(1356,0,__PYX_ERR(0, 1356, __pyx_L6_except_error)) __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils.cpath", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 1356, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_v_e = __pyx_t_2; /*try:*/ { /* … */ __Pyx_TraceLine(1356,0,__PYX_ERR(0, 1356, __pyx_L15_error)) /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L16; } __pyx_L15_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_5 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_5; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L6_except_error; } __pyx_L16:; } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L5_exception_handled; } goto __pyx_L6_except_error;
+1357: print(f"Error creating directory {savepath}: {e}")
__Pyx_TraceLine(1357,0,__PYX_ERR(0, 1357, __pyx_L15_error)) __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1357, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_kp_u_Error_creating_directory); __pyx_t_10 += 25; __Pyx_GIVEREF(__pyx_kp_u_Error_creating_directory); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Error_creating_directory); __pyx_t_12 = __Pyx_PyUnicode_Unicode(__pyx_v_savepath); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1357, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__68); __pyx_t_10 += 2; __Pyx_GIVEREF(__pyx_kp_u__68); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__68); __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1357, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_9, 4, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1357, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1357, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; }
1358: # Optionally, handle errors more gracefully or raise for critical issues
+1359: return str(savepath.resolve())
__Pyx_TraceLine(1359,0,__PYX_ERR(0, 1359, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_resolve, __pyx_v_savepath); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Str(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0;
1360:
1361:
+1362: def sPath (name_of_path:str):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_41sPath(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_40sPath, " Savepath func. Create a path with `name_of_path` if path not exists.\n \n :param name_of_path: str, Path-like object. If path does not exist,\n `name_of_path` should be created.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_41sPath = {"sPath", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_41sPath, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_40sPath}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_41sPath(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_name_of_path = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sPath (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name_of_path,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_of_path)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1362, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "sPath") < 0)) __PYX_ERR(0, 1362, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_name_of_path = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sPath", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1362, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.sPath", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name_of_path), (&PyUnicode_Type), 0, "name_of_path", 1))) __PYX_ERR(0, 1362, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_40sPath(__pyx_self, __pyx_v_name_of_path); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_40sPath(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name_of_path) { PyObject *__pyx_v_savepath = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__69) __Pyx_TraceCall("sPath", __pyx_f[0], 1362, 0, __PYX_ERR(0, 1362, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.sPath", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_savepath); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__378 = PyTuple_Pack(2, __pyx_n_s_name_of_path, __pyx_n_s_savepath); if (unlikely(!__pyx_tuple__378)) __PYX_ERR(0, 1362, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__378); __Pyx_GIVEREF(__pyx_tuple__378); /* … */ __Pyx_TraceLine(1362,0,__PYX_ERR(0, 1362, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_name_of_path, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1362, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_41sPath, 0, __pyx_n_s_sPath, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_sPath, __pyx_t_5) < 0) __PYX_ERR(0, 1362, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__378, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_sPath, 1362, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(0, 1362, __pyx_L1_error)
1363: """ Savepath func. Create a path with `name_of_path` if path not exists.
1364:
1365: :param name_of_path: str, Path-like object. If path does not exist,
1366: `name_of_path` should be created.
1367: """
1368:
+1369: try :
__Pyx_TraceLine(1369,0,__PYX_ERR(0, 1369, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L8_try_end:; }
+1370: savepath = os.path.join(os.getcwd(), name_of_path)
__Pyx_TraceLine(1370,0,__PYX_ERR(0, 1370, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_join); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_t_6, __pyx_v_name_of_path}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1370, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_savepath = __pyx_t_4; __pyx_t_4 = 0;
+1371: if not os.path.isdir(savepath):
__Pyx_TraceLine(1371,0,__PYX_ERR(0, 1371, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1371, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1371, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isdir); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1371, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_savepath}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1371, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1371, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_11 = (!__pyx_t_10); if (__pyx_t_11) { /* … */ }
+1372: os.mkdir(name_of_path)# mode =0o666)
__Pyx_TraceLine(1372,0,__PYX_ERR(0, 1372, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1372, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_mkdir); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1372, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_name_of_path}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1372, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1373: except :
__Pyx_TraceLine(1373,0,__PYX_ERR(0, 1373, __pyx_L5_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.sPath", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 1373, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+1374: warnings.warn("The path seems to be existed!")
__Pyx_TraceLine(1374,0,__PYX_ERR(0, 1374, __pyx_L5_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_warnings); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1374, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_warn); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1374, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_u_The_path_seems_to_be_existed}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1374, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1375: return
__Pyx_TraceLine(1375,0,__PYX_ERR(0, 1375, __pyx_L5_except_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; }
+1376: return savepath
__Pyx_TraceLine(1376,0,__PYX_ERR(0, 1376, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_savepath); __pyx_r = __pyx_v_savepath; goto __pyx_L0;
1377:
1378:
+1379: def format_notes(text:str , cover_str: str ='~', inline=70, **kws):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_43format_notes(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_42format_notes, " Format note \n :param text: Text to be formated.\n \n :param cover_str: type of ``str`` to surround the text.\n \n :param inline: Nomber of character before going in liine.\n \n :param margin_space: Must be <1 and expressed in %. The empty distance \n between the first index to the inline text \n :Example: \n \n >>> from gofast.tools import funcutils as func \n >>> text ='Automatic Option is set to ``True``.' ' Composite estimator building is triggered.' \n >>> func.format_notes(text= text ,\n ... inline = 70, margin_space = 0.05)\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_43format_notes = {"format_notes", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_43format_notes, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_42format_notes}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_43format_notes(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_text = 0; PyObject *__pyx_v_cover_str = 0; PyObject *__pyx_v_inline = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("format_notes (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_text,&__pyx_n_s_cover_str,&__pyx_n_s_inline,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_u__70))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_70))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_text)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1379, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cover_str); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1379, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_inline); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1379, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "format_notes") < 0)) __PYX_ERR(0, 1379, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_text = ((PyObject*)values[0]); __pyx_v_cover_str = ((PyObject*)values[1]); __pyx_v_inline = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("format_notes", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 1379, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.format_notes", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_text), (&PyUnicode_Type), 0, "text", 1))) __PYX_ERR(0, 1379, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cover_str), (&PyUnicode_Type), 0, "cover_str", 1))) __PYX_ERR(0, 1379, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_42format_notes(__pyx_self, __pyx_v_text, __pyx_v_cover_str, __pyx_v_inline, __pyx_v_kws); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_42format_notes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text, PyObject *__pyx_v_cover_str, PyObject *__pyx_v_inline, PyObject *__pyx_v_kws) { PyObject *__pyx_v_headnotes = NULL; PyObject *__pyx_v_margin_ratio = NULL; PyObject *__pyx_v_margin = NULL; PyObject *__pyx_v_init_ = NULL; PyObject *__pyx_v_new_textList = NULL; PyObject *__pyx_v_kk = NULL; CYTHON_UNUSED PyObject *__pyx_v_char = NULL; PyObject *__pyx_v_k = NULL; PyObject *__pyx_v_fmtin_str = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__71) __Pyx_TraceCall("format_notes", __pyx_f[0], 1379, 0, __PYX_ERR(0, 1379, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_AddTraceback("gofast.tools.coreutils.format_notes", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_headnotes); __Pyx_XDECREF(__pyx_v_margin_ratio); __Pyx_XDECREF(__pyx_v_margin); __Pyx_XDECREF(__pyx_v_init_); __Pyx_XDECREF(__pyx_v_new_textList); __Pyx_XDECREF(__pyx_v_kk); __Pyx_XDECREF(__pyx_v_char); __Pyx_XDECREF(__pyx_v_k); __Pyx_XDECREF(__pyx_v_fmtin_str); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__379 = PyTuple_Pack(13, __pyx_n_s_text, __pyx_n_s_cover_str, __pyx_n_s_inline, __pyx_n_s_kws_2, __pyx_n_s_headnotes, __pyx_n_s_margin_ratio, __pyx_n_s_margin, __pyx_n_s_init_2, __pyx_n_s_new_textList, __pyx_n_s_kk, __pyx_n_s_char, __pyx_n_s_k, __pyx_n_s_fmtin_str); if (unlikely(!__pyx_tuple__379)) __PYX_ERR(0, 1379, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__379); __Pyx_GIVEREF(__pyx_tuple__379); __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__379, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_format_notes, 1379, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) __PYX_ERR(0, 1379, __pyx_L1_error) /* … */ __Pyx_TraceLine(1379,0,__PYX_ERR(0, 1379, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_text, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1379, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_cover_str, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1379, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_43format_notes, 0, __pyx_n_s_format_notes, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__380); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_format_notes, __pyx_t_4) < 0) __PYX_ERR(0, 1379, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__380 = PyTuple_Pack(2, ((PyObject*)__pyx_kp_u__70), ((PyObject *)__pyx_int_70)); if (unlikely(!__pyx_tuple__380)) __PYX_ERR(0, 1379, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__380); __Pyx_GIVEREF(__pyx_tuple__380);
1380: """ Format note
1381: :param text: Text to be formated.
1382:
1383: :param cover_str: type of ``str`` to surround the text.
1384:
1385: :param inline: Nomber of character before going in liine.
1386:
1387: :param margin_space: Must be <1 and expressed in %. The empty distance
1388: between the first index to the inline text
1389: :Example:
1390:
1391: >>> from gofast.tools import funcutils as func
1392: >>> text ='Automatic Option is set to ``True``.'\
1393: ' Composite estimator building is triggered.'
1394: >>> func.format_notes(text= text ,
1395: ... inline = 70, margin_space = 0.05)
1396:
1397: """
1398:
+1399: headnotes =kws.pop('headernotes', 'notes')
__Pyx_TraceLine(1399,0,__PYX_ERR(0, 1399, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_headernotes, __pyx_n_u_notes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1399, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_headnotes = __pyx_t_1; __pyx_t_1 = 0;
+1400: margin_ratio = kws.pop('margin_space', 0.2 )
__Pyx_TraceLine(1400,0,__PYX_ERR(0, 1400, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_margin_space, __pyx_float_0_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_margin_ratio = __pyx_t_1; __pyx_t_1 = 0;
+1401: margin = int(margin_ratio * inline)
__Pyx_TraceLine(1401,0,__PYX_ERR(0, 1401, __pyx_L1_error)) __pyx_t_1 = PyNumber_Multiply(__pyx_v_margin_ratio, __pyx_v_inline); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_margin = __pyx_t_2; __pyx_t_2 = 0;
+1402: init_=0
__Pyx_TraceLine(1402,0,__PYX_ERR(0, 1402, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_v_init_ = __pyx_int_0;
+1403: new_textList= []
__Pyx_TraceLine(1403,0,__PYX_ERR(0, 1403, __pyx_L1_error)) __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_new_textList = __pyx_t_2; __pyx_t_2 = 0;
+1404: if len(text) <= (inline - margin):
__Pyx_TraceLine(1404,0,__PYX_ERR(0, 1404, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_text); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1404, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Subtract(__pyx_v_inline, __pyx_v_margin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1404, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1404, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { /* … */ goto __pyx_L3; }
+1405: new_textList = text
__Pyx_TraceLine(1405,0,__PYX_ERR(0, 1405, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_text); __Pyx_DECREF_SET(__pyx_v_new_textList, __pyx_v_text);
1406: else :
+1407: for kk, char in enumerate (text):
__Pyx_TraceLine(1407,0,__PYX_ERR(0, 1407, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_int_0); __pyx_t_4 = __pyx_int_0; __Pyx_INCREF(__pyx_v_text); __pyx_t_6 = __pyx_v_text; __pyx_t_10 = __Pyx_init_unicode_iteration(__pyx_t_6, (&__pyx_t_7), (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 1407, __pyx_L1_error) for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_7; __pyx_t_11++) { __pyx_t_3 = __pyx_t_11; __pyx_t_1 = __Pyx_PyUnicode_FromOrdinal(__Pyx_PyUnicode_READ(__pyx_t_9, __pyx_t_8, __pyx_t_3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_char, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1408,0,__PYX_ERR(0, 1408, __pyx_L1_error)) __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_kk, __pyx_t_4); /* … */ __Pyx_TraceLine(1407,0,__PYX_ERR(0, 1407, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = __pyx_t_1; __pyx_t_1 = 0;
+1408: if kk % (inline - margin)==0 and kk !=0:
__Pyx_TraceLine(1408,0,__PYX_ERR(0, 1408, __pyx_L1_error)) __pyx_t_1 = PyNumber_Subtract(__pyx_v_inline, __pyx_v_margin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Remainder(__pyx_v_kk, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_12) { } else { __pyx_t_5 = __pyx_t_12; goto __pyx_L7_bool_binop_done; } __pyx_t_12 = (__Pyx_PyInt_BoolNeObjC(__pyx_v_kk, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 1408, __pyx_L1_error) __pyx_t_5 = __pyx_t_12; __pyx_L7_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+1409: new_textList.append(text[init_:kk])
__Pyx_TraceLine(1409,0,__PYX_ERR(0, 1409, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_init_); __pyx_t_2 = __pyx_v_init_; __pyx_t_5 = (__pyx_t_2 == Py_None); if (__pyx_t_5) { __pyx_t_13 = 0; } else { __pyx_t_14 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_14 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1409, __pyx_L1_error) __pyx_t_13 = __pyx_t_14; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v_kk); __pyx_t_2 = __pyx_v_kk; __pyx_t_5 = (__pyx_t_2 == Py_None); if (__pyx_t_5) { __pyx_t_14 = PY_SSIZE_T_MAX; } else { __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1409, __pyx_L1_error) __pyx_t_14 = __pyx_t_15; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Substring(__pyx_v_text, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = __Pyx_PyObject_Append(__pyx_v_new_textList, __pyx_t_2); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1410: init_ =kk
__Pyx_TraceLine(1410,0,__PYX_ERR(0, 1410, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_kk); __Pyx_DECREF_SET(__pyx_v_init_, __pyx_v_kk);
+1411: if kk == len(text)-1:
__Pyx_TraceLine(1411,0,__PYX_ERR(0, 1411, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_text); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1411, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_14 - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1411, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_v_kk, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1411, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1411, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ } } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_L3:;
+1412: new_textList.append(text[init_:])
__Pyx_TraceLine(1412,0,__PYX_ERR(0, 1412, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_init_); __pyx_t_1 = __pyx_v_init_; __pyx_t_5 = (__pyx_t_1 == Py_None); if (__pyx_t_5) { __pyx_t_14 = 0; } else { __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1412, __pyx_L1_error) __pyx_t_14 = __pyx_t_13; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Substring(__pyx_v_text, __pyx_t_14, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_16 = __Pyx_PyObject_Append(__pyx_v_new_textList, __pyx_t_1); if (unlikely(__pyx_t_16 == ((int)-1))) __PYX_ERR(0, 1412, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1413:
+1414: print('!', headnotes.upper(), ':')
__Pyx_TraceLine(1414,0,__PYX_ERR(0, 1414, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_headnotes, __pyx_n_s_upper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_u__72); __Pyx_GIVEREF(__pyx_kp_u__72); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__72)) __PYX_ERR(0, 1414, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4)) __PYX_ERR(0, 1414, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__32); __Pyx_GIVEREF(__pyx_kp_u__32); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__32)) __PYX_ERR(0, 1414, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1415: print('{}'.format(cover_str * inline))
__Pyx_TraceLine(1415,0,__PYX_ERR(0, 1415, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyNumber_Multiply(__pyx_v_cover_str, __pyx_v_inline); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_17 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_t_2}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1416: for k in new_textList:
__Pyx_TraceLine(1416,0,__PYX_ERR(0, 1416, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_new_textList)) || PyTuple_CheckExact(__pyx_v_new_textList)) { __pyx_t_1 = __pyx_v_new_textList; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_18 = NULL; } else { __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_new_textList); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_18 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1416, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_18)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1416, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1416, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1416, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1416, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_18(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1416, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_k, __pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(1416,0,__PYX_ERR(0, 1416, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1417: fmtin_str ='{'+ '0:>{}'.format(margin) +'}'
__Pyx_TraceLine(1417,0,__PYX_ERR(0, 1417, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_17 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_v_margin}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyNumber_Add(__pyx_kp_u__74, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_kp_u__75); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_fmtin_str, __pyx_t_4); __pyx_t_4 = 0;
+1418: print('{0}{1:>2}{2:<51}'.format(fmtin_str.format(cover_str), '', k))
__Pyx_TraceLine(1418,0,__PYX_ERR(0, 1418, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_1_2_2_51, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_v_fmtin_str, __pyx_n_s_format); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_20 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_19))) { __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_19); if (likely(__pyx_t_20)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19); __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_19, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_v_cover_str}; __pyx_t_17 = __Pyx_PyObject_FastCall(__pyx_t_19, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } __pyx_t_19 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_19, __pyx_t_17, __pyx_kp_u__22, __pyx_v_k}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 3+__pyx_t_9); __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1419:
+1420: print('{0}{1:>51}'.format(' '* (margin -1), cover_str * (inline -margin+1 )))
__Pyx_TraceLine(1420,0,__PYX_ERR(0, 1420, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_1_51, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_margin, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_17 = PyNumber_Multiply(__pyx_kp_u__14, __pyx_t_4); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Subtract(__pyx_v_inline, __pyx_v_margin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_19 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Multiply(__pyx_v_cover_str, __pyx_t_19); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_19, __pyx_t_17, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1421:
1422:
+1423: def interpol_scipy(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_45interpol_scipy(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_44interpol_scipy, "\n Function to interpolate data using scipy's interp1d if available.\n \n Parameters \n ------------\n * x_value : np.ndarray \n Original abscissa values.\n \n * y_value : np.ndarray \n Original ordinate values (slope).\n \n * x_new : np.ndarray \n New abscissa values for which you want to interpolate data.\n \n * kind : str \n Type of interpolation, e.g., \"linear\", \"cubic\".\n \n * fill_value : str \n Extrapolation method. If None, scipy's interp1d will use constrained \n interpolation. \n Can be \"extrapolate\" to use fill_value.\n \n * plot : bool \n Set to True to plot a graph of the original and interpolated data.\n\n Returns \n --------\n np.ndarray \n Interpolated ordinate values for 'x_new'.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_45interpol_scipy = {"interpol_scipy", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_45interpol_scipy, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_44interpol_scipy}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_45interpol_scipy(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_x_value = 0; PyObject *__pyx_v_y_value = 0; PyObject *__pyx_v_x_new = 0; PyObject *__pyx_v_kind = 0; PyObject *__pyx_v_plot = 0; PyObject *__pyx_v_fill_value = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("interpol_scipy (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x_value,&__pyx_n_s_y_value,&__pyx_n_s_x_new,&__pyx_n_s_kind,&__pyx_n_s_plot,&__pyx_n_s_fill_value,0}; PyObject* values[6] = {0,0,0,0,0,0}; values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_linear))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_44interpol_scipy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x_value, PyObject *__pyx_v_y_value, PyObject *__pyx_v_x_new, PyObject *__pyx_v_kind, PyObject *__pyx_v_plot, PyObject *__pyx_v_fill_value) { PyObject *__pyx_v_spi = NULL; PyObject *__pyx_v_func_ = NULL; PyObject *__pyx_v_y_new = NULL; PyObject *__pyx_v_plt = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__76) __Pyx_TraceCall("interpol_scipy", __pyx_f[0], 1423, 0, __PYX_ERR(0, 1423, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.interpol_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_spi); __Pyx_XDECREF(__pyx_v_func_); __Pyx_XDECREF(__pyx_v_y_new); __Pyx_XDECREF(__pyx_v_plt); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__381 = PyTuple_Pack(11, __pyx_n_s_x_value, __pyx_n_s_y_value, __pyx_n_s_x_new, __pyx_n_s_kind, __pyx_n_s_plot, __pyx_n_s_fill_value, __pyx_n_s_spi, __pyx_n_s_func_2, __pyx_n_s_y_new, __pyx_n_s_plt, __pyx_n_s_e); if (unlikely(!__pyx_tuple__381)) __PYX_ERR(0, 1423, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__381); __Pyx_GIVEREF(__pyx_tuple__381); __pyx_codeobj__76 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__381, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_interpol_scipy, 1423, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__76)) __PYX_ERR(0, 1423, __pyx_L1_error) /* … */ __Pyx_TraceLine(1423,0,__PYX_ERR(0, 1423, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_45interpol_scipy, 0, __pyx_n_s_interpol_scipy, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__76)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__382); if (PyDict_SetItem(__pyx_d, __pyx_n_s_interpol_scipy, __pyx_t_4) < 0) __PYX_ERR(0, 1423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__382 = PyTuple_Pack(3, ((PyObject*)__pyx_n_u_linear), ((PyObject *)Py_False), ((PyObject*)__pyx_n_u_extrapolate)); if (unlikely(!__pyx_tuple__382)) __PYX_ERR(0, 1423, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__382); __Pyx_GIVEREF(__pyx_tuple__382);
1424: x_value,
1425: y_value,
1426: x_new,
1427: kind="linear",
+1428: plot=False,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_extrapolate))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1423, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_y_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1423, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("interpol_scipy", 0, 3, 6, 1); __PYX_ERR(0, 1423, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x_new)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1423, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("interpol_scipy", 0, 3, 6, 2); __PYX_ERR(0, 1423, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_kind); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1423, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_plot); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1423, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fill_value); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1423, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "interpol_scipy") < 0)) __PYX_ERR(0, 1423, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_x_value = values[0]; __pyx_v_y_value = values[1]; __pyx_v_x_new = values[2]; __pyx_v_kind = values[3]; __pyx_v_plot = values[4]; __pyx_v_fill_value = values[5]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("interpol_scipy", 0, 3, 6, __pyx_nargs); __PYX_ERR(0, 1423, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.interpol_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_44interpol_scipy(__pyx_self, __pyx_v_x_value, __pyx_v_y_value, __pyx_v_x_new, __pyx_v_kind, __pyx_v_plot, __pyx_v_fill_value);
1429: fill_value="extrapolate"
1430: ):
1431: """
1432: Function to interpolate data using scipy's interp1d if available.
1433:
1434: Parameters
1435: ------------
1436: * x_value : np.ndarray
1437: Original abscissa values.
1438:
1439: * y_value : np.ndarray
1440: Original ordinate values (slope).
1441:
1442: * x_new : np.ndarray
1443: New abscissa values for which you want to interpolate data.
1444:
1445: * kind : str
1446: Type of interpolation, e.g., "linear", "cubic".
1447:
1448: * fill_value : str
1449: Extrapolation method. If None, scipy's interp1d will use constrained
1450: interpolation.
1451: Can be "extrapolate" to use fill_value.
1452:
1453: * plot : bool
1454: Set to True to plot a graph of the original and interpolated data.
1455:
1456: Returns
1457: --------
1458: np.ndarray
1459: Interpolated ordinate values for 'x_new'.
1460: """
1461:
+1462: spi = check_scipy_interpolate()
__Pyx_TraceLine(1462,0,__PYX_ERR(0, 1462, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_scipy_interpolate); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_spi = __pyx_t_1; __pyx_t_1 = 0;
+1463: if spi is None:
__Pyx_TraceLine(1463,0,__PYX_ERR(0, 1463, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_spi == Py_None); if (__pyx_t_5) { /* … */ }
+1464: return None
__Pyx_TraceLine(1464,0,__PYX_ERR(0, 1464, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1465:
+1466: try:
__Pyx_TraceLine(1466,0,__PYX_ERR(0, 1466, __pyx_L1_error)) { /*try:*/ { /* … */ } __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L8_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; __pyx_L7_except_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; }
+1467: func_ = spi.interp1d(x_value, y_value, kind=kind, fill_value=fill_value)
__Pyx_TraceLine(1467,0,__PYX_ERR(0, 1467, __pyx_L4_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_spi, __pyx_n_s_interp1d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1467, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1467, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_x_value); __Pyx_GIVEREF(__pyx_v_x_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x_value)) __PYX_ERR(0, 1467, __pyx_L4_error); __Pyx_INCREF(__pyx_v_y_value); __Pyx_GIVEREF(__pyx_v_y_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_y_value)) __PYX_ERR(0, 1467, __pyx_L4_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1467, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_kind, __pyx_v_kind) < 0) __PYX_ERR(0, 1467, __pyx_L4_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_fill_value, __pyx_v_fill_value) < 0) __PYX_ERR(0, 1467, __pyx_L4_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1467, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_func_ = __pyx_t_9; __pyx_t_9 = 0;
+1468: y_new = func_(x_new)
__Pyx_TraceLine(1468,0,__PYX_ERR(0, 1468, __pyx_L4_error)) __Pyx_INCREF(__pyx_v_func_); __pyx_t_3 = __pyx_v_func_; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_x_new}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1468, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_y_new = __pyx_t_9; __pyx_t_9 = 0;
1469:
+1470: if plot:
__Pyx_TraceLine(1470,0,__PYX_ERR(0, 1470, __pyx_L4_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_plot); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1470, __pyx_L4_error) if (__pyx_t_5) { /* … */ }
+1471: import matplotlib.pyplot as plt
__Pyx_TraceLine(1471,0,__PYX_ERR(0, 1471, __pyx_L4_error)) __pyx_t_9 = __Pyx_ImportDottedModule(__pyx_n_s_matplotlib_pyplot, __pyx_tuple__77); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1471, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_plt = __pyx_t_9; __pyx_t_9 = 0; /* … */ __pyx_tuple__77 = PyTuple_Pack(2, __pyx_n_s_matplotlib, __pyx_n_s_pyplot); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1471, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__77); __Pyx_GIVEREF(__pyx_tuple__77);
+1472: plt.plot(x_value, y_value, "o", x_new, y_new, "--")
__Pyx_TraceLine(1472,0,__PYX_ERR(0, 1472, __pyx_L4_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_plot); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1472, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[7] = {__pyx_t_2, __pyx_v_x_value, __pyx_v_y_value, __pyx_n_u_o, __pyx_v_x_new, __pyx_v_y_new, __pyx_kp_u__78}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 6+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1472, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+1473: plt.legend(["Data", kind.capitalize()], loc="best")
__Pyx_TraceLine(1473,0,__PYX_ERR(0, 1473, __pyx_L4_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_legend); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_kind, __pyx_n_s_capitalize); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_u_Data); __Pyx_GIVEREF(__pyx_n_u_Data); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_Data)) __PYX_ERR(0, 1473, __pyx_L4_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L4_error); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L4_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_loc, __pyx_n_u_best) < 0) __PYX_ERR(0, 1473, __pyx_L4_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1473, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1474: plt.title(f"Interpolation: {kind.capitalize()}")
__Pyx_TraceLine(1474,0,__PYX_ERR(0, 1474, __pyx_L4_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_title); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1474, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_kind, __pyx_n_s_capitalize); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1474, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1474, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1474, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Interpolation, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1474, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1474, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1475: plt.xlabel("x")
__Pyx_TraceLine(1475,0,__PYX_ERR(0, 1475, __pyx_L4_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_xlabel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1475, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_x}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1475, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1476: plt.ylabel("y")
__Pyx_TraceLine(1476,0,__PYX_ERR(0, 1476, __pyx_L4_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_ylabel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1476, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_y_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1476, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1477: plt.grid(True)
__Pyx_TraceLine(1477,0,__PYX_ERR(0, 1477, __pyx_L4_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_grid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1477, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, Py_True}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1477, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1478: plt.show()
__Pyx_TraceLine(1478,0,__PYX_ERR(0, 1478, __pyx_L4_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_plt, __pyx_n_s_show); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1478, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1478, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1479:
+1480: return y_new
__Pyx_TraceLine(1480,0,__PYX_ERR(0, 1480, __pyx_L4_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_y_new); __pyx_r = __pyx_v_y_new; goto __pyx_L8_try_return;
1481:
+1482: except Exception as e:
__Pyx_TraceLine(1482,0,__PYX_ERR(0, 1482, __pyx_L6_except_error)) __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_4) { __Pyx_AddTraceback("gofast.tools.coreutils.interpol_scipy", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 1482, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_v_e = __pyx_t_2; /*try:*/ { /* … */ __Pyx_TraceLine(1482,0,__PYX_ERR(0, 1482, __pyx_L16_error)) /*finally:*/ { __pyx_L16_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_4 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_4; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L6_except_error; } __pyx_L15_return: { __pyx_t_20 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; __pyx_r = __pyx_t_20; __pyx_t_20 = 0; goto __pyx_L7_except_return; } } } goto __pyx_L6_except_error;
+1483: _logger.error(f"An unexpected error occurred during interpolation: {e}")
__Pyx_TraceLine(1483,0,__PYX_ERR(0, 1483, __pyx_L16_error)) __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1483, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_error); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1483, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1483, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = __Pyx_PyUnicode_Concat(__pyx_kp_u_An_unexpected_error_occurred_dur, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1483, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_12}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1483, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+1484: return None
__Pyx_TraceLine(1484,0,__PYX_ERR(0, 1484, __pyx_L16_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L15_return; }
1485:
+1486: def _remove_str_word (ch, word_to_remove, deep_remove=False):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_47_remove_str_word(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_46_remove_str_word, "\n Small funnction to remove a word present on astring character \n whatever the number of times it will repeated.\n \n Parameters\n ----------\n * ch : str\n may the the str phrases or sentences . main items.\n * word_to_remove : str\n specific word to remove.\n * deep_remove : bool, optional\n use the lower case to remove the word even the word is uppercased \n of capitalized. The default is False.\n\n Returns\n -------\n str ; char , new_char without the removed word .\n \n Examples\n ---------\n >>> from gofast.tools import funcutils as func\n >>> ch ='AMTAVG 7.76: \"K1.fld\", Dated 99-01-01,AMTAVG, \n ... Processed 11 Jul 17 AMTAVG'\n >>> ss=func._remove_str_word(char=ch, word_to_remove='AMTAVG', \n ... deep_remove=False)\n >>> print(ss)\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_47_remove_str_word = {"_remove_str_word", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_47_remove_str_word, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_46_remove_str_word}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_47_remove_str_word(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_ch = 0; PyObject *__pyx_v_word_to_remove = 0; PyObject *__pyx_v_deep_remove = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_remove_str_word (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ch,&__pyx_n_s_word_to_remove,&__pyx_n_s_deep_remove,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ch)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1486, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_word_to_remove)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1486, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_remove_str_word", 0, 2, 3, 1); __PYX_ERR(0, 1486, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep_remove); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1486, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_remove_str_word") < 0)) __PYX_ERR(0, 1486, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ch = values[0]; __pyx_v_word_to_remove = values[1]; __pyx_v_deep_remove = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_remove_str_word", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 1486, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._remove_str_word", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_46_remove_str_word(__pyx_self, __pyx_v_ch, __pyx_v_word_to_remove, __pyx_v_deep_remove); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_46_remove_str_word(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ch, PyObject *__pyx_v_word_to_remove, PyObject *__pyx_v_deep_remove) { PyObject *__pyx_v_char = NULL; PyObject *__pyx_v_index_wr = NULL; PyObject *__pyx_v_remain_len = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__79) __Pyx_TraceCall("_remove_str_word", __pyx_f[0], 1486, 0, __PYX_ERR(0, 1486, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_word_to_remove); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils._remove_str_word", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_char); __Pyx_XDECREF(__pyx_v_index_wr); __Pyx_XDECREF(__pyx_v_remain_len); __Pyx_XDECREF(__pyx_v_word_to_remove); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__383 = PyTuple_Pack(6, __pyx_n_s_ch, __pyx_n_s_word_to_remove, __pyx_n_s_deep_remove, __pyx_n_s_char, __pyx_n_s_index_wr, __pyx_n_s_remain_len); if (unlikely(!__pyx_tuple__383)) __PYX_ERR(0, 1486, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__383); __Pyx_GIVEREF(__pyx_tuple__383); __pyx_codeobj__79 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__383, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_remove_str_word, 1486, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__79)) __PYX_ERR(0, 1486, __pyx_L1_error) /* … */ __Pyx_TraceLine(1486,0,__PYX_ERR(0, 1486, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_47_remove_str_word, 0, __pyx_n_s_remove_str_word, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__79)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1486, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__384); if (PyDict_SetItem(__pyx_d, __pyx_n_s_remove_str_word, __pyx_t_4) < 0) __PYX_ERR(0, 1486, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__384 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__384)) __PYX_ERR(0, 1486, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__384); __Pyx_GIVEREF(__pyx_tuple__384);
1487: """
1488: Small funnction to remove a word present on astring character
1489: whatever the number of times it will repeated.
1490:
1491: Parameters
1492: ----------
1493: * ch : str
1494: may the the str phrases or sentences . main items.
1495: * word_to_remove : str
1496: specific word to remove.
1497: * deep_remove : bool, optional
1498: use the lower case to remove the word even the word is uppercased
1499: of capitalized. The default is False.
1500:
1501: Returns
1502: -------
1503: str ; char , new_char without the removed word .
1504:
1505: Examples
1506: ---------
1507: >>> from gofast.tools import funcutils as func
1508: >>> ch ='AMTAVG 7.76: "K1.fld", Dated 99-01-01,AMTAVG,
1509: ... Processed 11 Jul 17 AMTAVG'
1510: >>> ss=func._remove_str_word(char=ch, word_to_remove='AMTAVG',
1511: ... deep_remove=False)
1512: >>> print(ss)
1513:
1514: """
+1515: if type(ch) is not str : char =str(ch)
__Pyx_TraceLine(1515,0,__PYX_ERR(0, 1515, __pyx_L1_error)) __pyx_t_1 = (((PyObject *)Py_TYPE(__pyx_v_ch)) != ((PyObject *)(&PyUnicode_Type))); if (__pyx_t_1) { __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_ch); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_char = __pyx_t_2; __pyx_t_2 = 0; }
+1516: if type(word_to_remove) is not str : word_to_remove=str(word_to_remove)
__Pyx_TraceLine(1516,0,__PYX_ERR(0, 1516, __pyx_L1_error)) __pyx_t_1 = (((PyObject *)Py_TYPE(__pyx_v_word_to_remove)) != ((PyObject *)(&PyUnicode_Type))); if (__pyx_t_1) { __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_word_to_remove); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_word_to_remove, __pyx_t_2); __pyx_t_2 = 0; }
1517:
+1518: if deep_remove == True :
__Pyx_TraceLine(1518,0,__PYX_ERR(0, 1518, __pyx_L1_error)) __pyx_t_2 = PyObject_RichCompare(__pyx_v_deep_remove, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1518, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1518, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+1519: word_to_remove, char =word_to_remove.lower(),char.lower()
__Pyx_TraceLine(1519,0,__PYX_ERR(0, 1519, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_word_to_remove, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1519, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_char, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1519, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_word_to_remove, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_char, __pyx_t_3); __pyx_t_3 = 0;
1520:
+1521: if word_to_remove not in char :
__Pyx_TraceLine(1521,0,__PYX_ERR(0, 1521, __pyx_L1_error)) if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1521, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_word_to_remove, __pyx_v_char, Py_NE)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1521, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+1522: return char
__Pyx_TraceLine(1522,0,__PYX_ERR(0, 1522, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1522, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_char); __pyx_r = __pyx_v_char; goto __pyx_L0;
1523:
+1524: while word_to_remove in char :
__Pyx_TraceLine(1524,0,__PYX_ERR(0, 1524, __pyx_L1_error)) while (1) { if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1524, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_word_to_remove, __pyx_v_char, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1524, __pyx_L1_error) if (!__pyx_t_1) break;
+1525: if word_to_remove not in char :
__Pyx_TraceLine(1525,0,__PYX_ERR(0, 1525, __pyx_L1_error)) if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1525, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_v_word_to_remove, __pyx_v_char, Py_NE)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1525, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+1526: break
__Pyx_TraceLine(1526,0,__PYX_ERR(0, 1526, __pyx_L1_error)) goto __pyx_L8_break;
+1527: index_wr = char.find(word_to_remove)
__Pyx_TraceLine(1527,0,__PYX_ERR(0, 1527, __pyx_L1_error)) if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1527, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_char, __pyx_n_s_find); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_word_to_remove}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_XDECREF_SET(__pyx_v_index_wr, __pyx_t_3); __pyx_t_3 = 0;
+1528: remain_len=index_wr+len(word_to_remove)
__Pyx_TraceLine(1528,0,__PYX_ERR(0, 1528, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_word_to_remove); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1528, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Add(__pyx_v_index_wr, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_remain_len, __pyx_t_2); __pyx_t_2 = 0;
+1529: char=char[:index_wr]+char[remain_len:]
__Pyx_TraceLine(1529,0,__PYX_ERR(0, 1529, __pyx_L1_error)) if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1529, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_char, 0, 0, NULL, &__pyx_v_index_wr, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1529, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_char, 0, 0, &__pyx_v_remain_len, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1529, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_char, __pyx_t_4); __pyx_t_4 = 0; } __pyx_L8_break:;
1530:
+1531: return char
__Pyx_TraceLine(1531,0,__PYX_ERR(0, 1531, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_char)) { __Pyx_RaiseUnboundLocalError("char"); __PYX_ERR(0, 1531, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_char); __pyx_r = __pyx_v_char; goto __pyx_L0;
1532:
+1533: def stn_check_split_type(data_lines):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_49stn_check_split_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_48stn_check_split_type, "\n Read data_line and check for data line the presence of \n split_type < ',' or ' ', or any other marks.>\n Threshold is assume to be third of total data length.\n \n :params data_lines: list of data to parse . \n :type data_lines: list \n \n :returns: The split _type\n :rtype: str\n \n :Example: \n >>> from gofast.tools import funcutils as func\n >>> path = data/ K6.stn\n >>> with open (path, 'r', encoding='utf8') as f : \n ... data= f.readlines()\n >>> print(func.stn_check_split_type(data_lines=data))\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_49stn_check_split_type = {"stn_check_split_type", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_49stn_check_split_type, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_48stn_check_split_type}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_49stn_check_split_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data_lines = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("stn_check_split_type (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data_lines,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data_lines)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1533, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "stn_check_split_type") < 0)) __PYX_ERR(0, 1533, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_data_lines = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("stn_check_split_type", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1533, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.stn_check_split_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_48stn_check_split_type(__pyx_self, __pyx_v_data_lines); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_48stn_check_split_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data_lines) { PyObject *__pyx_v_split_type = NULL; PyObject *__pyx_v_data_to_read = NULL; CYTHON_UNUSED PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_item = NULL; CYTHON_UNUSED PyObject *__pyx_v_jj = NULL; PyObject *__pyx_v_sep = NULL; PyObject *__pyx_9genexpr19__pyx_v_item = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__80) __Pyx_TraceCall("stn_check_split_type", __pyx_f[0], 1533, 0, __PYX_ERR(0, 1533, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_data_lines); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.stn_check_split_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_split_type); __Pyx_XDECREF(__pyx_v_data_to_read); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_jj); __Pyx_XDECREF(__pyx_v_sep); __Pyx_XDECREF(__pyx_9genexpr19__pyx_v_item); __Pyx_XDECREF(__pyx_v_data_lines); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__385 = PyTuple_Pack(8, __pyx_n_s_data_lines, __pyx_n_s_split_type, __pyx_n_s_data_to_read, __pyx_n_s_ii, __pyx_n_s_item, __pyx_n_s_jj, __pyx_n_s_sep, __pyx_n_s_item); if (unlikely(!__pyx_tuple__385)) __PYX_ERR(0, 1533, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__385); __Pyx_GIVEREF(__pyx_tuple__385); /* … */ __Pyx_TraceLine(1533,0,__PYX_ERR(0, 1533, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_49stn_check_split_type, 0, __pyx_n_s_stn_check_split_type, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__80)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1533, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_stn_check_split_type, __pyx_t_4) < 0) __PYX_ERR(0, 1533, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__80 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__385, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_stn_check_split_type, 1533, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__80)) __PYX_ERR(0, 1533, __pyx_L1_error)
1534: """
1535: Read data_line and check for data line the presence of
1536: split_type < ',' or ' ', or any other marks.>
1537: Threshold is assume to be third of total data length.
1538:
1539: :params data_lines: list of data to parse .
1540: :type data_lines: list
1541:
1542: :returns: The split _type
1543: :rtype: str
1544:
1545: :Example:
1546: >>> from gofast.tools import funcutils as func
1547: >>> path = data/ K6.stn
1548: >>> with open (path, 'r', encoding='utf8') as f :
1549: ... data= f.readlines()
1550: >>> print(func.stn_check_split_type(data_lines=data))
1551:
1552: """
1553:
+1554: split_type =[',', ':',' ',';' ]
__Pyx_TraceLine(1554,0,__PYX_ERR(0, 1554, __pyx_L1_error)) __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1554, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_u__48); __Pyx_GIVEREF(__pyx_kp_u__48); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__48)) __PYX_ERR(0, 1554, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__32); __Pyx_GIVEREF(__pyx_kp_u__32); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__32)) __PYX_ERR(0, 1554, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__14); __Pyx_GIVEREF(__pyx_kp_u__14); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14)) __PYX_ERR(0, 1554, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__49); __Pyx_GIVEREF(__pyx_kp_u__49); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__49)) __PYX_ERR(0, 1554, __pyx_L1_error); __pyx_v_split_type = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1555: data_to_read =[]
__Pyx_TraceLine(1555,0,__PYX_ERR(0, 1555, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1555, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_data_to_read = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
1556: # change the data if data is not dtype string elements.
+1557: if isinstance(data_lines, np.ndarray):
__Pyx_TraceLine(1557,0,__PYX_ERR(0, 1557, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_data_lines, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 1557, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+1558: if data_lines.dtype in ['float', 'int', 'complex']:
__Pyx_TraceLine(1558,0,__PYX_ERR(0, 1558, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_lines, __pyx_n_s_dtype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_float, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1558, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_int, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1558, __pyx_L1_error) if (!__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_complex, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1558, __pyx_L1_error) __pyx_t_3 = __pyx_t_4; __pyx_L5_bool_binop_done:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_3; if (__pyx_t_4) { /* … */ }
+1559: data_lines=data_lines.astype('<U12')
__Pyx_TraceLine(1559,0,__PYX_ERR(0, 1559, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_lines, __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1559, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_kp_u_U12}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1559, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_data_lines, __pyx_t_2); __pyx_t_2 = 0;
+1560: data_lines= data_lines.tolist()
__Pyx_TraceLine(1560,0,__PYX_ERR(0, 1560, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data_lines, __pyx_n_s_tolist); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_data_lines, __pyx_t_2); __pyx_t_2 = 0;
1561:
+1562: if isinstance(data_lines, list):
__Pyx_TraceLine(1562,0,__PYX_ERR(0, 1562, __pyx_L1_error)) __pyx_t_4 = PyList_Check(__pyx_v_data_lines); if (__pyx_t_4) { /* … */ goto __pyx_L8; }
+1563: for ii, item in enumerate(data_lines[:int(len(data_lines)/3)]):
__Pyx_TraceLine(1563,0,__PYX_ERR(0, 1563, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_2 = __pyx_int_0; __pyx_t_7 = PyObject_Length(__pyx_v_data_lines); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1563, __pyx_L1_error) __pyx_t_1 = __Pyx_PyInt_FromDouble((((double)__pyx_t_7) / 3.0)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_data_lines, 0, 0, NULL, &__pyx_t_1, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1563, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1563, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1563, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1563, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1563, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_8(__pyx_t_1); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1563, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_2); __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1563, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(1563,0,__PYX_ERR(0, 1563, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1564: data_to_read.append(item)
__Pyx_TraceLine(1564,0,__PYX_ERR(0, 1564, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_data_to_read, __pyx_v_item); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1564, __pyx_L1_error)
1565: # be sure the list is str item .
+1566: data_to_read=[''.join([str(item) for item in data_to_read])]
__Pyx_TraceLine(1566,0,__PYX_ERR(0, 1566, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1566, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __pyx_v_data_to_read; __Pyx_INCREF(__pyx_t_10); __pyx_t_11 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_10); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1566, __pyx_L13_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_12 = PyList_GET_ITEM(__pyx_t_10, __pyx_t_11); __Pyx_INCREF(__pyx_t_12); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 1566, __pyx_L13_error) #else __pyx_t_12 = __Pyx_PySequence_ITEM(__pyx_t_10, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1566, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_12); #endif __Pyx_XDECREF_SET(__pyx_9genexpr19__pyx_v_item, __pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_Str(__pyx_9genexpr19__pyx_v_item); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1566, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_12); if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_12))) __PYX_ERR(0, 1566, __pyx_L13_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_9genexpr19__pyx_v_item); __pyx_9genexpr19__pyx_v_item = 0; goto __pyx_L17_exit_scope; __pyx_L13_error:; __Pyx_XDECREF(__pyx_9genexpr19__pyx_v_item); __pyx_9genexpr19__pyx_v_item = 0; goto __pyx_L1_error; __pyx_L17_exit_scope:; } /* exit inner scope */ __pyx_t_10 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1566, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1566, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_10)) __PYX_ERR(0, 1566, __pyx_L1_error); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_data_to_read, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
1567:
+1568: elif isinstance(data_lines, str): data_to_read=[str(data_lines)]
__Pyx_TraceLine(1568,0,__PYX_ERR(0, 1568, __pyx_L1_error)) __pyx_t_4 = PyUnicode_Check(__pyx_v_data_lines); if (__pyx_t_4) { __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_data_lines); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2)) __PYX_ERR(0, 1568, __pyx_L1_error); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_data_to_read, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; } __pyx_L8:;
1569:
+1570: for jj, sep in enumerate(split_type) :
__Pyx_TraceLine(1570,0,__PYX_ERR(0, 1570, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; __pyx_t_2 = __pyx_v_split_type; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1570, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1570, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_v_sep, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_jj, __pyx_t_1); __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1570, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(1570,0,__PYX_ERR(0, 1570, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1571: if data_to_read[0].find(sep) > 0 :
__Pyx_TraceLine(1571,0,__PYX_ERR(0, 1571, __pyx_L1_error)) __pyx_t_10 = __Pyx_GetItemInt_List(__pyx_v_data_to_read, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_find); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_sep}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = PyObject_RichCompare(__pyx_t_5, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1571, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1571, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_4) { /* … */ }
+1572: if data_to_read[0].count(sep) >= 2 * len(data_lines)/3:
__Pyx_TraceLine(1572,0,__PYX_ERR(0, 1572, __pyx_L1_error)) __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_data_to_read, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_count); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_sep}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_11 = PyObject_Length(__pyx_v_data_lines); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1572, __pyx_L1_error) __pyx_t_10 = PyFloat_FromDouble((((double)(2 * __pyx_t_11)) / 3.0)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = PyObject_RichCompare(__pyx_t_12, __pyx_t_10, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1572, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_4) { /* … */ }
+1573: if sep == ' ': return None # use None more conventional
__Pyx_TraceLine(1573,0,__PYX_ERR(0, 1573, __pyx_L1_error)) __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_sep, __pyx_kp_u__14, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1573, __pyx_L1_error) if (__pyx_t_4) { __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; }
+1574: else : return sep
__Pyx_TraceLine(1574,0,__PYX_ERR(0, 1574, __pyx_L1_error)) /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_sep); __pyx_r = __pyx_v_sep; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; }
1575:
1576:
+1577: def round_dipole_length(value, round_value =5.):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_51round_dipole_length(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_50round_dipole_length, " \n small function to graduate dipole length 5 to 5. Goes to be reality and \n simple computation .\n \n :param value: value of dipole length \n :type value: float \n \n :returns: value of dipole length rounded 5 to 5 \n :rtype: float\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_51round_dipole_length = {"round_dipole_length", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_51round_dipole_length, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_50round_dipole_length}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_51round_dipole_length(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_value = 0; PyObject *__pyx_v_round_value = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("round_dipole_length (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_round_value,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_5_))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1577, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_round_value); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1577, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "round_dipole_length") < 0)) __PYX_ERR(0, 1577, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_value = values[0]; __pyx_v_round_value = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("round_dipole_length", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 1577, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.round_dipole_length", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_50round_dipole_length(__pyx_self, __pyx_v_value, __pyx_v_round_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_50round_dipole_length(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value, PyObject *__pyx_v_round_value) { PyObject *__pyx_v_mm = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__81) __Pyx_TraceCall("round_dipole_length", __pyx_f[0], 1577, 0, __PYX_ERR(0, 1577, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.round_dipole_length", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_mm); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__386 = PyTuple_Pack(3, __pyx_n_s_value, __pyx_n_s_round_value, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__386)) __PYX_ERR(0, 1577, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__386); __Pyx_GIVEREF(__pyx_tuple__386); __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__386, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_round_dipole_length, 1577, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 1577, __pyx_L1_error) /* … */ __Pyx_TraceLine(1577,0,__PYX_ERR(0, 1577, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_51round_dipole_length, 0, __pyx_n_s_round_dipole_length, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1577, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__387); if (PyDict_SetItem(__pyx_d, __pyx_n_s_round_dipole_length, __pyx_t_4) < 0) __PYX_ERR(0, 1577, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__387 = PyTuple_Pack(1, ((PyObject*)__pyx_float_5_)); if (unlikely(!__pyx_tuple__387)) __PYX_ERR(0, 1577, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__387); __Pyx_GIVEREF(__pyx_tuple__387);
1578: """
1579: small function to graduate dipole length 5 to 5. Goes to be reality and
1580: simple computation .
1581:
1582: :param value: value of dipole length
1583: :type value: float
1584:
1585: :returns: value of dipole length rounded 5 to 5
1586: :rtype: float
1587: """
+1588: mm = value % round_value
__Pyx_TraceLine(1588,0,__PYX_ERR(0, 1588, __pyx_L1_error)) __pyx_t_1 = PyNumber_Remainder(__pyx_v_value, __pyx_v_round_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1588, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mm = __pyx_t_1; __pyx_t_1 = 0;
+1589: if mm < 3 :return np.around(value - mm)
__Pyx_TraceLine(1589,0,__PYX_ERR(0, 1589, __pyx_L1_error)) __pyx_t_1 = PyObject_RichCompare(__pyx_v_mm, __pyx_int_3, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1589, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_around); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Subtract(__pyx_v_value, __pyx_v_mm); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
+1590: elif mm >= 3 and mm < 7 :return np.around(value -mm +round_value)
__Pyx_TraceLine(1590,0,__PYX_ERR(0, 1590, __pyx_L1_error)) __pyx_t_1 = PyObject_RichCompare(__pyx_v_mm, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1590, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_7) { } else { __pyx_t_2 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_1 = PyObject_RichCompare(__pyx_v_mm, __pyx_int_7, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1590, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_7; __pyx_L4_bool_binop_done:; if (__pyx_t_2) { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_around); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Subtract(__pyx_v_value, __pyx_v_mm); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_v_round_value); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1590, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
+1591: else:return np.around(value - mm +10.)
__Pyx_TraceLine(1591,0,__PYX_ERR(0, 1591, __pyx_L1_error)) /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_around); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Subtract(__pyx_v_value, __pyx_v_mm); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyFloat_AddObjC(__pyx_t_3, __pyx_float_10_, 10., 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1591, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
1592:
+1593: def display_infos(infos, **kws):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_53display_infos(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_52display_infos, " Display unique element on list of array infos\n \n :param infos: Iterable object to display. \n :param header: Change the `header` to other names. \n \n :Example: \n >>> from gofast.tools.coreutils import display_infos\n >>> ipts= ['river water', 'fracture zone', 'granite', 'gravel',\n 'sedimentary rocks', 'massive sulphide', 'igneous rocks', \n 'gravel', 'sedimentary rocks']\n >>> display_infos('infos= ipts,header='TestAutoRocks', \n size =77, inline='~')\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_53display_infos = {"display_infos", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_53display_infos, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_52display_infos}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_53display_infos(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_infos = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("display_infos (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_infos,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_infos)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1593, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "display_infos") < 0)) __PYX_ERR(0, 1593, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_infos = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("display_infos", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1593, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.display_infos", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_52display_infos(__pyx_self, __pyx_v_infos, __pyx_v_kws); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_52display_infos(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_infos, PyObject *__pyx_v_kws) { PyObject *__pyx_v_inline = NULL; PyObject *__pyx_v_size = NULL; PyObject *__pyx_v_header = NULL; PyObject *__pyx_v_mes = NULL; PyObject *__pyx_v_am = NULL; PyObject *__pyx_v_ii = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__82) __Pyx_TraceCall("display_infos", __pyx_f[0], 1593, 0, __PYX_ERR(0, 1593, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_infos); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.display_infos", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_inline); __Pyx_XDECREF(__pyx_v_size); __Pyx_XDECREF(__pyx_v_header); __Pyx_XDECREF(__pyx_v_mes); __Pyx_XDECREF(__pyx_v_am); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_infos); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_56generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_tuple__388 = PyTuple_Pack(8, __pyx_n_s_infos, __pyx_n_s_kws_2, __pyx_n_s_inline, __pyx_n_s_size, __pyx_n_s_header, __pyx_n_s_mes, __pyx_n_s_am, __pyx_n_s_ii); if (unlikely(!__pyx_tuple__388)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__388); __Pyx_GIVEREF(__pyx_tuple__388); /* … */ __Pyx_TraceLine(1593,0,__PYX_ERR(0, 1593, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_53display_infos, 0, __pyx_n_s_display_infos, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__82)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_display_infos, __pyx_t_4) < 0) __PYX_ERR(0, 1593, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__82 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__388, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_display_infos, 1593, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__82)) __PYX_ERR(0, 1593, __pyx_L1_error)
1594: """ Display unique element on list of array infos
1595:
1596: :param infos: Iterable object to display.
1597: :param header: Change the `header` to other names.
1598:
1599: :Example:
1600: >>> from gofast.tools.coreutils import display_infos
1601: >>> ipts= ['river water', 'fracture zone', 'granite', 'gravel',
1602: 'sedimentary rocks', 'massive sulphide', 'igneous rocks',
1603: 'gravel', 'sedimentary rocks']
1604: >>> display_infos('infos= ipts,header='TestAutoRocks',
1605: size =77, inline='~')
1606: """
1607:
+1608: inline =kws.pop('inline', '-')
__Pyx_TraceLine(1608,0,__PYX_ERR(0, 1608, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_inline, __pyx_kp_u__29); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_inline = __pyx_t_1; __pyx_t_1 = 0;
+1609: size =kws.pop('size', 70)
__Pyx_TraceLine(1609,0,__PYX_ERR(0, 1609, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_size, __pyx_int_70); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1609, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_size = __pyx_t_1; __pyx_t_1 = 0;
+1610: header =kws.pop('header', 'Automatic rocks')
__Pyx_TraceLine(1610,0,__PYX_ERR(0, 1610, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_header, __pyx_kp_u_Automatic_rocks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_header = __pyx_t_1; __pyx_t_1 = 0;
1611:
+1612: if isinstance(infos, str ):
__Pyx_TraceLine(1612,0,__PYX_ERR(0, 1612, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Check(__pyx_v_infos); if (__pyx_t_2) { /* … */ }
+1613: infos =[infos]
__Pyx_TraceLine(1613,0,__PYX_ERR(0, 1613, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_infos); __Pyx_GIVEREF(__pyx_v_infos); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_infos)) __PYX_ERR(0, 1613, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_infos, __pyx_t_1); __pyx_t_1 = 0;
1614:
+1615: infos = list(set(infos))
__Pyx_TraceLine(1615,0,__PYX_ERR(0, 1615, __pyx_L1_error)) __pyx_t_1 = PySet_New(__pyx_v_infos); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PySequence_List(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_infos, __pyx_t_3); __pyx_t_3 = 0;
+1616: print(inline * size )
__Pyx_TraceLine(1616,0,__PYX_ERR(0, 1616, __pyx_L1_error)) __pyx_t_3 = PyNumber_Multiply(__pyx_v_inline, __pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1617: mes= '{0}({1:02})'.format(header.capitalize(),
__Pyx_TraceLine(1617,0,__PYX_ERR(0, 1617, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_1_02, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_header, __pyx_n_s_capitalize); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
+1618: len(infos))
__Pyx_TraceLine(1618,0,__PYX_ERR(0, 1618, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_infos); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1618, __pyx_L1_error) __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_4, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_mes = __pyx_t_1; __pyx_t_1 = 0;
+1619: mes = '{0:^70}'.format(mes)
__Pyx_TraceLine(1619,0,__PYX_ERR(0, 1619, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_70, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_mes}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_mes, __pyx_t_1); __pyx_t_1 = 0;
+1620: print(mes)
__Pyx_TraceLine(1620,0,__PYX_ERR(0, 1620, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_mes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1620, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1621: print(inline * size )
__Pyx_TraceLine(1621,0,__PYX_ERR(0, 1621, __pyx_L1_error)) __pyx_t_1 = PyNumber_Multiply(__pyx_v_inline, __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1622: am=''
__Pyx_TraceLine(1622,0,__PYX_ERR(0, 1622, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__22); __pyx_v_am = __pyx_kp_u__22;
+1623: for ii in range(len(infos)):
__Pyx_TraceLine(1623,0,__PYX_ERR(0, 1623, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_infos); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1623, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1623, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1623, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1623, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1623, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1623, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1623, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1623,0,__PYX_ERR(0, 1623, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1624: if (ii+1) %2 ==0:
__Pyx_TraceLine(1624,0,__PYX_ERR(0, 1624, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyInt_RemainderObjC(__pyx_t_1, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_5, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1624, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L6; }
+1625: am = am + '{0:>4}.{1:<30}'.format(ii+1, infos[ii].capitalize())
__Pyx_TraceLine(1625,0,__PYX_ERR(0, 1625, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_4_1_30, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_v_infos, __pyx_v_ii); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_capitalize); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_t_4, __pyx_t_6}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyNumber_Add(__pyx_v_am, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_am, __pyx_t_1); __pyx_t_1 = 0;
+1626: print(am)
__Pyx_TraceLine(1626,0,__PYX_ERR(0, 1626, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_am); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1627: am=''
__Pyx_TraceLine(1627,0,__PYX_ERR(0, 1627, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__22); __Pyx_DECREF_SET(__pyx_v_am, __pyx_kp_u__22);
1628: else:
+1629: am ='{0:>4}.{1:<30}'.format(ii+1, infos[ii].capitalize())
__Pyx_TraceLine(1629,0,__PYX_ERR(0, 1629, __pyx_L1_error)) /*else*/ { __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_4_1_30, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_v_infos, __pyx_v_ii); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_capitalize); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_t_6, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1629, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_am, __pyx_t_1); __pyx_t_1 = 0;
+1630: if ii ==len(infos)-1:
__Pyx_TraceLine(1630,0,__PYX_ERR(0, 1630, __pyx_L1_error)) __pyx_t_12 = PyObject_Length(__pyx_v_infos); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1630, __pyx_L1_error) __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_12 - 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1630, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyObject_RichCompare(__pyx_v_ii, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1630, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 1630, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_2) { /* … */ } } __pyx_L6:;
+1631: print(am)
__Pyx_TraceLine(1631,0,__PYX_ERR(0, 1631, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_am); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+1632: print(inline * size )
__Pyx_TraceLine(1632,0,__PYX_ERR(0, 1632, __pyx_L1_error)) __pyx_t_3 = PyNumber_Multiply(__pyx_v_inline, __pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1633:
+1634: def fr_en_parser (f, delimiter =':'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_55fr_en_parser(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_54fr_en_parser, " Parse the translated data file. \n \n :param f: translation file to parse.\n \n :param delimiter: str, delimiter.\n \n :return: generator obj, composed of a list of \n french and english Input translation. \n \n :Example:\n >>> file_to_parse = 'pme.parserf.md'\n >>> path_pme_data = r'C:/Users\\Administrator\\Desktop\\__elodata\n >>> data =list(BS.fr_en_parser(\n os.path.join(path_pme_data, file_to_parse)))\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_55fr_en_parser = {"fr_en_parser", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_55fr_en_parser, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_54fr_en_parser}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_55fr_en_parser(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_f = 0; PyObject *__pyx_v_delimiter = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fr_en_parser (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_f,&__pyx_n_s_delimiter,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__32))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_f)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1634, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_delimiter); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1634, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "fr_en_parser") < 0)) __PYX_ERR(0, 1634, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_f = values[0]; __pyx_v_delimiter = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fr_en_parser", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 1634, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.fr_en_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_54fr_en_parser(__pyx_self, __pyx_v_f, __pyx_v_delimiter); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_54fr_en_parser(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f, PyObject *__pyx_v_delimiter) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_4_fr_en_parser *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_4_fr_en_parser *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_4_fr_en_parser(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_4_fr_en_parser, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_4_fr_en_parser *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1634, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_f = __pyx_v_f; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f); __pyx_cur_scope->__pyx_v_delimiter = __pyx_v_delimiter; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_delimiter); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_delimiter); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_56generator, __pyx_codeobj__83, (PyObject *) __pyx_cur_scope, __pyx_n_s_fr_en_parser, __pyx_n_s_fr_en_parser, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 1634, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("gofast.tools.coreutils.fr_en_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_56generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fr_en_parser", 0); __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__83) __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1634, __pyx_L1_error) /* … */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("fr_en_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__389 = PyTuple_Pack(8, __pyx_n_s_f, __pyx_n_s_delimiter, __pyx_n_s_is_file, __pyx_n_s_ft, __pyx_n_s_data, __pyx_n_s_row, __pyx_n_s_fr, __pyx_n_s_en); if (unlikely(!__pyx_tuple__389)) __PYX_ERR(0, 1634, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__389); __Pyx_GIVEREF(__pyx_tuple__389); __pyx_codeobj__83 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__389, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fr_en_parser, 1634, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__83)) __PYX_ERR(0, 1634, __pyx_L1_error) /* … */ __Pyx_TraceLine(1634,0,__PYX_ERR(0, 1634, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_55fr_en_parser, 0, __pyx_n_s_fr_en_parser, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__83)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__390); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fr_en_parser, __pyx_t_4) < 0) __PYX_ERR(0, 1634, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__390 = PyTuple_Pack(1, ((PyObject*)__pyx_kp_u__32)); if (unlikely(!__pyx_tuple__390)) __PYX_ERR(0, 1634, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__390); __Pyx_GIVEREF(__pyx_tuple__390); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_4_fr_en_parser { PyObject_HEAD PyObject *__pyx_v_data; PyObject *__pyx_v_delimiter; PyObject *__pyx_v_en; PyObject *__pyx_v_f; PyObject *__pyx_v_fr; PyObject *__pyx_v_ft; PyObject *__pyx_v_is_file; PyObject *__pyx_v_row; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *__pyx_t_2; PyObject *__pyx_t_3; PyObject *__pyx_t_4; PyObject *__pyx_t_5; PyObject *(*__pyx_t_6)(PyObject *); };
1635: """ Parse the translated data file.
1636:
1637: :param f: translation file to parse.
1638:
1639: :param delimiter: str, delimiter.
1640:
1641: :return: generator obj, composed of a list of
1642: french and english Input translation.
1643:
1644: :Example:
1645: >>> file_to_parse = 'pme.parserf.md'
1646: >>> path_pme_data = r'C:/Users\Administrator\Desktop\__elodata
1647: >>> data =list(BS.fr_en_parser(
1648: os.path.join(path_pme_data, file_to_parse)))
1649: """
1650:
+1651: is_file = os.path.isfile (f)
__Pyx_TraceLine(1651,0,__PYX_ERR(0, 1651, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isfile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_f}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_is_file = __pyx_t_1; __pyx_t_1 = 0;
+1652: if not is_file:
__Pyx_TraceLine(1652,0,__PYX_ERR(0, 1652, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_file); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1652, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_5); if (unlikely(__pyx_t_6)) { /* … */ }
+1653: raise IOError(f'Input {f} is not a file. Please check your file.')
__Pyx_TraceLine(1653,0,__PYX_ERR(0, 1653, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Input); __pyx_t_7 += 6; __Pyx_GIVEREF(__pyx_kp_u_Input); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Input); __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_f, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_is_not_a_file_Please_check_your); __pyx_t_7 += 39; __Pyx_GIVEREF(__pyx_kp_u_is_not_a_file_Please_check_your); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_is_not_a_file_Please_check_your); __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IOError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1653, __pyx_L1_error)
1654:
+1655: with open(f, 'r', encoding ='utf8') as ft:
__Pyx_TraceLine(1655,0,__PYX_ERR(0, 1655, __pyx_L1_error)) /*with:*/ { __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_f)) __PYX_ERR(0, 1655, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_r); __Pyx_GIVEREF(__pyx_n_u_r); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_r)) __PYX_ERR(0, 1655, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 1655, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1655, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1655, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_ft = __pyx_t_1; __pyx_t_1 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L14_try_end; __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.fr_en_parser", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 1655, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_10 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1655, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1655, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__pyx_t_5 < 0) __PYX_ERR(0, 1655, __pyx_L11_except_error) __pyx_t_6 = (!__pyx_t_5); if (unlikely(__pyx_t_6)) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_3, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 1655, __pyx_L11_except_error) } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L10_exception_handled; } __pyx_L11_except_error:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L1_error; __pyx_L10_exception_handled:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); __pyx_L14_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_9) { __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } goto __pyx_L8; } __pyx_L8:; } goto __pyx_L27; __pyx_L5_error:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L1_error; __pyx_L27:; } CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope); /* … */ __pyx_tuple__84 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 1655, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__84); __Pyx_GIVEREF(__pyx_tuple__84);
+1656: data = ft.readlines()
__Pyx_TraceLine(1656,0,__PYX_ERR(0, 1656, __pyx_L9_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_ft, __pyx_n_s_readlines); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1656, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1656, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_data = __pyx_t_1; __pyx_t_1 = 0;
+1657: for row in data :
__Pyx_TraceLine(1657,0,__PYX_ERR(0, 1657, __pyx_L9_error)) if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_data)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_data)) { __pyx_t_1 = __pyx_cur_scope->__pyx_v_data; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_14 = NULL; } else { __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1657, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1657, __pyx_L9_error) } for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1657, __pyx_L9_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1657, __pyx_L9_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1657, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1657, __pyx_L9_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 1657, __pyx_L9_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1657, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1657, __pyx_L9_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(1657,0,__PYX_ERR(0, 1657, __pyx_L9_error)) __pyx_L15_continue:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1658: if row in ( '\n', ' '):
__Pyx_TraceLine(1658,0,__PYX_ERR(0, 1658, __pyx_L9_error)) __Pyx_INCREF(__pyx_cur_scope->__pyx_v_row); __pyx_t_3 = __pyx_cur_scope->__pyx_v_row; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u__11, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1658, __pyx_L9_error) if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L18_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u__14, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1658, __pyx_L9_error) __pyx_t_6 = __pyx_t_5; __pyx_L18_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __pyx_t_6; if (__pyx_t_5) { /* … */ }
+1659: continue
__Pyx_TraceLine(1659,0,__PYX_ERR(0, 1659, __pyx_L9_error)) goto __pyx_L15_continue;
+1660: fr, en = row.strip().split(delimiter)
__Pyx_TraceLine(1660,0,__PYX_ERR(0, 1660, __pyx_L9_error)) __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_row, __pyx_n_s_strip); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_delimiter}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1660, __pyx_L9_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_10 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_15 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1660, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_15); index = 0; __pyx_t_10 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_10)) goto __pyx_L20_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); index = 1; __pyx_t_2 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_2)) goto __pyx_L20_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 2) < 0) __PYX_ERR(0, 1660, __pyx_L9_error) __pyx_t_16 = NULL; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L21_unpacking_done; __pyx_L20_unpacking_failed:; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_16 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1660, __pyx_L9_error) __pyx_L21_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_fr); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_fr, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_en); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_en, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
+1661: yield([fr, en])
__Pyx_TraceLine(1661,0,__PYX_ERR(0, 1661, __pyx_L9_error)) __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1661, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fr); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fr); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_fr)) __PYX_ERR(0, 1661, __pyx_L9_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_en); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_en); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_en)) __PYX_ERR(0, 1661, __pyx_L9_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_7; __Pyx_XGIVEREF(__pyx_t_9); __pyx_cur_scope->__pyx_t_2 = __pyx_t_9; __Pyx_XGIVEREF(__pyx_t_11); __pyx_cur_scope->__pyx_t_3 = __pyx_t_11; __Pyx_XGIVEREF(__pyx_t_12); __pyx_cur_scope->__pyx_t_4 = __pyx_t_12; __Pyx_XGIVEREF(__pyx_t_13); __pyx_cur_scope->__pyx_t_5 = __pyx_t_13; __pyx_cur_scope->__pyx_t_6 = __pyx_t_14; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L22_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_7 = __pyx_cur_scope->__pyx_t_1; __pyx_t_9 = __pyx_cur_scope->__pyx_t_2; __pyx_cur_scope->__pyx_t_2 = 0; __Pyx_XGOTREF(__pyx_t_9); __pyx_t_11 = __pyx_cur_scope->__pyx_t_3; __pyx_cur_scope->__pyx_t_3 = 0; __Pyx_XGOTREF(__pyx_t_11); __pyx_t_12 = __pyx_cur_scope->__pyx_t_4; __pyx_cur_scope->__pyx_t_4 = 0; __Pyx_XGOTREF(__pyx_t_12); __pyx_t_13 = __pyx_cur_scope->__pyx_t_5; __pyx_cur_scope->__pyx_t_5 = 0; __Pyx_XGOTREF(__pyx_t_13); __pyx_t_14 = __pyx_cur_scope->__pyx_t_6; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1661, __pyx_L9_error)
1662:
+1663: def convert_csvdata_from_fr_to_en(csv_fn, pf, destfile = 'pme.en.csv',
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_58convert_csvdata_from_fr_to_en(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_57convert_csvdata_from_fr_to_en, " Translate variable data from french csv data to english with \n parser file. \n \n :param csv_fn: data collected in csv format.\n \n :param pf: parser file. \n \n :param destfile: str, Destination file, outputfile.\n \n :param savepath: Path-Like object, save data to a path. \n \n :Example: \n # to execute this script, we need to import the two modules below\n >>> import os \n >>> import csv \n >>> from gofast.tools.coreutils import convert_csvdata_from_fr_to_en\n >>> path_pme_data = r'C:/Users\\Administrator\\Desktop\\__elodata\n >>> datalist=convert_csvdata_from_fr_to_en(\n os.path.join( path_pme_data, _enuv2.csv') , \n os.path.join(path_pme_data, pme.parserf.md')\n savefile = 'pme.en.cv')\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_58convert_csvdata_from_fr_to_en = {"convert_csvdata_from_fr_to_en", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_58convert_csvdata_from_fr_to_en, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_57convert_csvdata_from_fr_to_en}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_58convert_csvdata_from_fr_to_en(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_csv_fn = 0; PyObject *__pyx_v_pf = 0; PyObject *__pyx_v_destfile = 0; PyObject *__pyx_v_savepath = 0; PyObject *__pyx_v_delimiter = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_csvdata_from_fr_to_en (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_csv_fn,&__pyx_n_s_pf,&__pyx_n_s_destfile,&__pyx_n_s_savepath,&__pyx_n_s_delimiter,0}; PyObject* values[5] = {0,0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u_pme_en_csv))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_57convert_csvdata_from_fr_to_en(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csv_fn, PyObject *__pyx_v_pf, PyObject *__pyx_v_destfile, PyObject *__pyx_v_savepath, PyObject *__pyx_v_delimiter) { PyObject *__pyx_v_parser_data = NULL; PyObject *__pyx_v_csv_f = NULL; PyObject *__pyx_v_csv_reader = NULL; PyObject *__pyx_v_csv_data = NULL; PyObject *__pyx_v_ix = NULL; PyObject *__pyx_v_csv_1b = NULL; PyObject *__pyx_v_csv_2b = NULL; PyObject *__pyx_v_csv_1bb = NULL; PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_rowline = NULL; PyObject *__pyx_v_jj = NULL; PyObject *__pyx_v_row = NULL; PyObject *__pyx_v_fr_v = NULL; PyObject *__pyx_v_en_v = NULL; PyObject *__pyx_v_new_csv_list = NULL; PyObject *__pyx_v_csvf = NULL; PyObject *__pyx_v_csv_writer = NULL; PyObject *__pyx_9genexpr20__pyx_v_row = NULL; PyObject *__pyx_9genexpr21__pyx_v_row = NULL; PyObject *__pyx_9genexpr22__pyx_v_row = NULL; PyObject *__pyx_9genexpr23__pyx_v_r1 = NULL; PyObject *__pyx_9genexpr23__pyx_v_r2 = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__85) __Pyx_TraceCall("convert_csvdata_from_fr_to_en", __pyx_f[0], 1663, 0, __PYX_ERR(0, 1663, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_destfile); __Pyx_INCREF(__pyx_v_savepath); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_XDECREF(__pyx_t_21); __Pyx_XDECREF(__pyx_t_22); __Pyx_AddTraceback("gofast.tools.coreutils.convert_csvdata_from_fr_to_en", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_parser_data); __Pyx_XDECREF(__pyx_v_csv_f); __Pyx_XDECREF(__pyx_v_csv_reader); __Pyx_XDECREF(__pyx_v_csv_data); __Pyx_XDECREF(__pyx_v_ix); __Pyx_XDECREF(__pyx_v_csv_1b); __Pyx_XDECREF(__pyx_v_csv_2b); __Pyx_XDECREF(__pyx_v_csv_1bb); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_rowline); __Pyx_XDECREF(__pyx_v_jj); __Pyx_XDECREF(__pyx_v_row); __Pyx_XDECREF(__pyx_v_fr_v); __Pyx_XDECREF(__pyx_v_en_v); __Pyx_XDECREF(__pyx_v_new_csv_list); __Pyx_XDECREF(__pyx_v_csvf); __Pyx_XDECREF(__pyx_v_csv_writer); __Pyx_XDECREF(__pyx_9genexpr20__pyx_v_row); __Pyx_XDECREF(__pyx_9genexpr21__pyx_v_row); __Pyx_XDECREF(__pyx_9genexpr22__pyx_v_row); __Pyx_XDECREF(__pyx_9genexpr23__pyx_v_r1); __Pyx_XDECREF(__pyx_9genexpr23__pyx_v_r2); __Pyx_XDECREF(__pyx_v_destfile); __Pyx_XDECREF(__pyx_v_savepath); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_61generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_tuple__391 = PyTuple_Pack(27, __pyx_n_s_csv_fn, __pyx_n_s_pf, __pyx_n_s_destfile, __pyx_n_s_savepath, __pyx_n_s_delimiter, __pyx_n_s_parser_data, __pyx_n_s_csv_f, __pyx_n_s_csv_reader, __pyx_n_s_csv_data, __pyx_n_s_ix, __pyx_n_s_csv_1b, __pyx_n_s_csv_2b, __pyx_n_s_csv_1bb, __pyx_n_s_ii, __pyx_n_s_rowline, __pyx_n_s_jj, __pyx_n_s_row, __pyx_n_s_fr_v, __pyx_n_s_en_v, __pyx_n_s_new_csv_list, __pyx_n_s_csvf, __pyx_n_s_csv_writer, __pyx_n_s_row, __pyx_n_s_row, __pyx_n_s_row, __pyx_n_s_r1, __pyx_n_s_r2); if (unlikely(!__pyx_tuple__391)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__391); __Pyx_GIVEREF(__pyx_tuple__391); __pyx_codeobj__85 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 27, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__391, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_convert_csvdata_from_fr_to_en, 1663, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__85)) __PYX_ERR(0, 1663, __pyx_L1_error) /* … */ __Pyx_TraceLine(1663,0,__PYX_ERR(0, 1663, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_58convert_csvdata_from_fr_to_en, 0, __pyx_n_s_convert_csvdata_from_fr_to_en, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__85)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__392); if (PyDict_SetItem(__pyx_d, __pyx_n_s_convert_csvdata_from_fr_to_en, __pyx_t_4) < 0) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__392 = PyTuple_Pack(3, ((PyObject*)__pyx_kp_u_pme_en_csv), Py_None, ((PyObject*)__pyx_kp_u__32)); if (unlikely(!__pyx_tuple__392)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__392); __Pyx_GIVEREF(__pyx_tuple__392);
+1664: savepath =None, delimiter =':'):
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__32))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_csv_fn)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1663, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pf)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1663, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("convert_csvdata_from_fr_to_en", 0, 2, 5, 1); __PYX_ERR(0, 1663, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_destfile); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1663, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1663, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_delimiter); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1663, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "convert_csvdata_from_fr_to_en") < 0)) __PYX_ERR(0, 1663, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_csv_fn = values[0]; __pyx_v_pf = values[1]; __pyx_v_destfile = values[2]; __pyx_v_savepath = values[3]; __pyx_v_delimiter = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("convert_csvdata_from_fr_to_en", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 1663, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.convert_csvdata_from_fr_to_en", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_57convert_csvdata_from_fr_to_en(__pyx_self, __pyx_v_csv_fn, __pyx_v_pf, __pyx_v_destfile, __pyx_v_savepath, __pyx_v_delimiter);
1665: """ Translate variable data from french csv data to english with
1666: parser file.
1667:
1668: :param csv_fn: data collected in csv format.
1669:
1670: :param pf: parser file.
1671:
1672: :param destfile: str, Destination file, outputfile.
1673:
1674: :param savepath: Path-Like object, save data to a path.
1675:
1676: :Example:
1677: # to execute this script, we need to import the two modules below
1678: >>> import os
1679: >>> import csv
1680: >>> from gofast.tools.coreutils import convert_csvdata_from_fr_to_en
1681: >>> path_pme_data = r'C:/Users\Administrator\Desktop\__elodata
1682: >>> datalist=convert_csvdata_from_fr_to_en(
1683: os.path.join( path_pme_data, _enuv2.csv') ,
1684: os.path.join(path_pme_data, pme.parserf.md')
1685: savefile = 'pme.en.cv')
1686: """
1687: # read the parser file and separed english from french
+1688: parser_data = list(fr_en_parser (pf,delimiter) )
__Pyx_TraceLine(1688,0,__PYX_ERR(0, 1688, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_fr_en_parser); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_pf, __pyx_v_delimiter}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_parser_data = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
1689:
+1690: with open (csv_fn, 'r', encoding ='utf8') as csv_f :
__Pyx_TraceLine(1690,0,__PYX_ERR(0, 1690, __pyx_L1_error)) /*with:*/ { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_csv_fn); __Pyx_GIVEREF(__pyx_v_csv_fn); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csv_fn)) __PYX_ERR(0, 1690, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_r); __Pyx_GIVEREF(__pyx_n_u_r); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_r)) __PYX_ERR(0, 1690, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 1690, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1690, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1690, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __pyx_v_csv_f = __pyx_t_2; __pyx_t_2 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.convert_csvdata_from_fr_to_en", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 1690, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1690, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1690, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_13 < 0) __PYX_ERR(0, 1690, __pyx_L9_except_error) __pyx_t_14 = (!__pyx_t_13); if (unlikely(__pyx_t_14)) { __Pyx_GIVEREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; __PYX_ERR(0, 1690, __pyx_L9_except_error) } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_L12_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } goto __pyx_L6; } __pyx_L6:; } goto __pyx_L23; __pyx_L3_error:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L1_error; __pyx_L23:; }
+1691: csv_reader = csv.reader(csv_f)
__Pyx_TraceLine(1691,0,__PYX_ERR(0, 1691, __pyx_L7_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_csv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1691, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1691, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_csv_f}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1691, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_csv_reader = __pyx_t_2; __pyx_t_2 = 0;
+1692: csv_data =[ row for row in csv_reader]
__Pyx_TraceLine(1692,0,__PYX_ERR(0, 1692, __pyx_L7_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1692, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_v_csv_reader)) || PyTuple_CheckExact(__pyx_v_csv_reader)) { __pyx_t_1 = __pyx_v_csv_reader; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_csv_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1692, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1692, __pyx_L15_error) } for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1692, __pyx_L15_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1692, __pyx_L15_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1692, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1692, __pyx_L15_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1692, __pyx_L15_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1692, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1692, __pyx_L15_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_9genexpr20__pyx_v_row, __pyx_t_3); __pyx_t_3 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_9genexpr20__pyx_v_row))) __PYX_ERR(0, 1692, __pyx_L15_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr20__pyx_v_row); __pyx_9genexpr20__pyx_v_row = 0; goto __pyx_L19_exit_scope; __pyx_L15_error:; __Pyx_XDECREF(__pyx_9genexpr20__pyx_v_row); __pyx_9genexpr20__pyx_v_row = 0; goto __pyx_L7_error; __pyx_L19_exit_scope:; } /* exit inner scope */ __pyx_v_csv_data = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
1693: # get the index of the last substring row
+1694: ix = csv_data [0].index ('Industry_type')
__Pyx_TraceLine(1694,0,__PYX_ERR(0, 1694, __pyx_L1_error)) if (unlikely(!__pyx_v_csv_data)) { __Pyx_RaiseUnboundLocalError("csv_data"); __PYX_ERR(0, 1694, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_csv_data, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_n_u_Industry_type}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_ix = __pyx_t_3; __pyx_t_3 = 0;
1695: # separateblock from two
+1696: csv_1b = [row [:ix +1] for row in csv_data]
__Pyx_TraceLine(1696,0,__PYX_ERR(0, 1696, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1696, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_v_csv_data)) { __Pyx_RaiseUnboundLocalError("csv_data"); __PYX_ERR(0, 1696, __pyx_L26_error) } __pyx_t_2 = __pyx_v_csv_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1696, __pyx_L26_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1696, __pyx_L26_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1696, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_9genexpr21__pyx_v_row, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ix, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1696, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_9genexpr21__pyx_v_row, 0, 0, NULL, &__pyx_t_1, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1696, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 1696, __pyx_L26_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr21__pyx_v_row); __pyx_9genexpr21__pyx_v_row = 0; goto __pyx_L30_exit_scope; __pyx_L26_error:; __Pyx_XDECREF(__pyx_9genexpr21__pyx_v_row); __pyx_9genexpr21__pyx_v_row = 0; goto __pyx_L1_error; __pyx_L30_exit_scope:; } /* exit inner scope */ __pyx_v_csv_1b = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1697: csv_2b =[row [ix+1:] for row in csv_data ]
__Pyx_TraceLine(1697,0,__PYX_ERR(0, 1697, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1697, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_v_csv_data)) { __Pyx_RaiseUnboundLocalError("csv_data"); __PYX_ERR(0, 1697, __pyx_L33_error) } __pyx_t_2 = __pyx_v_csv_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1697, __pyx_L33_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1697, __pyx_L33_error) #else __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1697, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_XDECREF_SET(__pyx_9genexpr22__pyx_v_row, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_ix, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1697, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_9genexpr22__pyx_v_row, 0, 0, &__pyx_t_6, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1697, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1697, __pyx_L33_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr22__pyx_v_row); __pyx_9genexpr22__pyx_v_row = 0; goto __pyx_L37_exit_scope; __pyx_L33_error:; __Pyx_XDECREF(__pyx_9genexpr22__pyx_v_row); __pyx_9genexpr22__pyx_v_row = 0; goto __pyx_L1_error; __pyx_L37_exit_scope:; } /* exit inner scope */ __pyx_v_csv_2b = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
1698: # make a copy of csv_1b
+1699: csv_1bb= copy.deepcopy(csv_1b)
__Pyx_TraceLine(1699,0,__PYX_ERR(0, 1699, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_csv_1b}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_csv_1bb = __pyx_t_3; __pyx_t_3 = 0;
1700:
+1701: for ii, rowline in enumerate( csv_1bb[3:]) : # skip the first two rows
__Pyx_TraceLine(1701,0,__PYX_ERR(0, 1701, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_3 = __pyx_int_0; __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_csv_1bb, 3, 0, NULL, NULL, &__pyx_slice__86, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1701, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1701, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1701, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1701, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1701, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1701, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_rowline, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_3); __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; /* … */ __pyx_slice__86 = PySlice_New(__pyx_int_3, Py_None, Py_None); if (unlikely(!__pyx_slice__86)) __PYX_ERR(0, 1701, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__86); __Pyx_GIVEREF(__pyx_slice__86); /* … */ __Pyx_TraceLine(1701,0,__PYX_ERR(0, 1701, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1702: for jj , row in enumerate(rowline):
__Pyx_TraceLine(1702,0,__PYX_ERR(0, 1702, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_rowline)) || PyTuple_CheckExact(__pyx_v_rowline)) { __pyx_t_6 = __pyx_v_rowline; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; __pyx_t_16 = NULL; } else { __pyx_t_15 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_rowline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1702, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_16)) { if (likely(PyList_CheckExact(__pyx_t_6))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1702, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_17 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_17); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 1702, __pyx_L1_error) #else __pyx_t_17 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1702, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_17 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_17); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 1702, __pyx_L1_error) #else __pyx_t_17 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); #endif } } else { __pyx_t_17 = __pyx_t_16(__pyx_t_6); if (unlikely(!__pyx_t_17)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1702, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_17); } __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_17); __pyx_t_17 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_jj, __pyx_t_1); __pyx_t_17 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_17; __pyx_t_17 = 0; /* … */ __Pyx_TraceLine(1702,0,__PYX_ERR(0, 1702, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1703: for (fr_v, en_v) in parser_data:
__Pyx_TraceLine(1703,0,__PYX_ERR(0, 1703, __pyx_L1_error)) __pyx_t_17 = __pyx_v_parser_data; __Pyx_INCREF(__pyx_t_17); __pyx_t_18 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_17); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1703, __pyx_L1_error) #endif if (__pyx_t_18 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_19 = PyList_GET_ITEM(__pyx_t_17, __pyx_t_18); __Pyx_INCREF(__pyx_t_19); __pyx_t_18++; if (unlikely((0 < 0))) __PYX_ERR(0, 1703, __pyx_L1_error) #else __pyx_t_19 = __Pyx_PySequence_ITEM(__pyx_t_17, __pyx_t_18); __pyx_t_18++; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); #endif if ((likely(PyTuple_CheckExact(__pyx_t_19))) || (PyList_CheckExact(__pyx_t_19))) { PyObject* sequence = __pyx_t_19; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1703, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_20 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_21 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_20 = PyList_GET_ITEM(sequence, 0); __pyx_t_21 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(__pyx_t_21); #else __pyx_t_20 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_21 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); #endif __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } else { Py_ssize_t index = -1; __pyx_t_22 = PyObject_GetIter(__pyx_t_19); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_23 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_22); index = 0; __pyx_t_20 = __pyx_t_23(__pyx_t_22); if (unlikely(!__pyx_t_20)) goto __pyx_L44_unpacking_failed; __Pyx_GOTREF(__pyx_t_20); index = 1; __pyx_t_21 = __pyx_t_23(__pyx_t_22); if (unlikely(!__pyx_t_21)) goto __pyx_L44_unpacking_failed; __Pyx_GOTREF(__pyx_t_21); if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_22), 2) < 0) __PYX_ERR(0, 1703, __pyx_L1_error) __pyx_t_23 = NULL; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; goto __pyx_L45_unpacking_done; __pyx_L44_unpacking_failed:; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; __pyx_t_23 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1703, __pyx_L1_error) __pyx_L45_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_fr_v, __pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF_SET(__pyx_v_en_v, __pyx_t_21); __pyx_t_21 = 0; /* … */ __Pyx_TraceLine(1703,0,__PYX_ERR(0, 1703, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
1704: # remove the space from french parser part
1705: # this could reduce the mistyping error
+1706: fr_v= fr_v.replace(
__Pyx_TraceLine(1706,0,__PYX_ERR(0, 1706, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_v_fr_v, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; /* … */ __pyx_tuple__87 = PyTuple_Pack(2, __pyx_kp_u__14, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__87)) __PYX_ERR(0, 1706, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__87); __Pyx_GIVEREF(__pyx_tuple__87);
+1707: ' ', '').replace('(', '').replace(
__Pyx_TraceLine(1707,0,__PYX_ERR(0, 1707, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; /* … */ __pyx_tuple__88 = PyTuple_Pack(2, __pyx_kp_u__53, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 1707, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__88); __Pyx_GIVEREF(__pyx_tuple__88); __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1707, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_tuple__89 = PyTuple_Pack(2, __pyx_kp_u__56, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__89)) __PYX_ERR(0, 1707, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__89); __Pyx_GIVEREF(__pyx_tuple__89);
+1708: ')', '').replace('\\', '').lower()
__Pyx_TraceLine(1708,0,__PYX_ERR(0, 1708, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_lower); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_21))) { __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21); if (likely(__pyx_t_20)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_21, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_20, NULL}; __pyx_t_19 = __Pyx_PyObject_FastCall(__pyx_t_21, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __Pyx_DECREF_SET(__pyx_v_fr_v, __pyx_t_19); __pyx_t_19 = 0; /* … */ __pyx_tuple__91 = PyTuple_Pack(2, __pyx_kp_u__90, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__91)) __PYX_ERR(0, 1708, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__91); __Pyx_GIVEREF(__pyx_tuple__91);
1709: # go for reading the half of the sentence
+1710: row = row.lower().replace(
__Pyx_TraceLine(1710,0,__PYX_ERR(0, 1710, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_lower); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_20 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_21))) { __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21); if (likely(__pyx_t_20)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_21, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_20, NULL}; __pyx_t_19 = __Pyx_PyObject_FastCall(__pyx_t_21, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__87, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
+1711: ' ', '').replace('(', '').replace(
__Pyx_TraceLine(1711,0,__PYX_ERR(0, 1711, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__89, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
+1712: ')', '').replace('\\', '')
__Pyx_TraceLine(1712,0,__PYX_ERR(0, 1712, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_n_s_replace); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_tuple__91, NULL); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF_SET(__pyx_v_row, __pyx_t_19); __pyx_t_19 = 0;
+1713: if row.find(fr_v[: int(len(fr_v)/2)]) >=0:
__Pyx_TraceLine(1713,0,__PYX_ERR(0, 1713, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_find); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_24 = PyObject_Length(__pyx_v_fr_v); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1713, __pyx_L1_error) __pyx_t_20 = __Pyx_PyInt_FromDouble((((double)__pyx_t_24) / 2.0)); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_22 = __Pyx_PyObject_GetSlice(__pyx_v_fr_v, 0, 0, NULL, &__pyx_t_20, NULL, 0, 0, 1); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_21))) { __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21); if (likely(__pyx_t_20)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); __Pyx_INCREF(__pyx_t_20); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_21, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_22}; __pyx_t_19 = __Pyx_PyObject_FastCall(__pyx_t_21, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __pyx_t_21 = PyObject_RichCompare(__pyx_t_19, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_21); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_21); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; if (__pyx_t_14) { /* … */ }
+1714: csv_1bb[3:][ii][jj] = en_v
__Pyx_TraceLine(1714,0,__PYX_ERR(0, 1714, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_GetSlice(__pyx_v_csv_1bb, 3, 0, NULL, NULL, &__pyx_slice__86, 1, 0, 1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_19 = __Pyx_PyObject_GetItem(__pyx_t_21, __pyx_v_ii); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1714, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; if (unlikely((PyObject_SetItem(__pyx_t_19, __pyx_v_jj, __pyx_v_en_v) < 0))) __PYX_ERR(0, 1714, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
1715:
1716: # once translation is done, concatenate list
+1717: new_csv_list = [r1 + r2 for r1, r2 in zip(csv_1bb,csv_2b )]
__Pyx_TraceLine(1717,0,__PYX_ERR(0, 1717, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_csv_1bb); __Pyx_GIVEREF(__pyx_v_csv_1bb); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csv_1bb)) __PYX_ERR(0, 1717, __pyx_L52_error); __Pyx_INCREF(__pyx_v_csv_2b); __Pyx_GIVEREF(__pyx_v_csv_2b); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_csv_2b)) __PYX_ERR(0, 1717, __pyx_L52_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1717, __pyx_L52_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1717, __pyx_L52_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1717, __pyx_L52_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1717, __pyx_L52_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1717, __pyx_L52_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1717, __pyx_L52_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1717, __pyx_L52_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_17 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_17 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_17); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_17 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_17); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_19 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_23 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_19); index = 0; __pyx_t_6 = __pyx_t_23(__pyx_t_19); if (unlikely(!__pyx_t_6)) goto __pyx_L55_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_17 = __pyx_t_23(__pyx_t_19); if (unlikely(!__pyx_t_17)) goto __pyx_L55_unpacking_failed; __Pyx_GOTREF(__pyx_t_17); if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_19), 2) < 0) __PYX_ERR(0, 1717, __pyx_L52_error) __pyx_t_23 = NULL; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L56_unpacking_done; __pyx_L55_unpacking_failed:; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_23 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1717, __pyx_L52_error) __pyx_L56_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_9genexpr23__pyx_v_r1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_9genexpr23__pyx_v_r2, __pyx_t_17); __pyx_t_17 = 0; __pyx_t_1 = PyNumber_Add(__pyx_9genexpr23__pyx_v_r1, __pyx_9genexpr23__pyx_v_r2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1717, __pyx_L52_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr23__pyx_v_r1); __pyx_9genexpr23__pyx_v_r1 = 0; __Pyx_XDECREF(__pyx_9genexpr23__pyx_v_r2); __pyx_9genexpr23__pyx_v_r2 = 0; goto __pyx_L58_exit_scope; __pyx_L52_error:; __Pyx_XDECREF(__pyx_9genexpr23__pyx_v_r1); __pyx_9genexpr23__pyx_v_r1 = 0; __Pyx_XDECREF(__pyx_9genexpr23__pyx_v_r2); __pyx_9genexpr23__pyx_v_r2 = 0; goto __pyx_L1_error; __pyx_L58_exit_scope:; } /* exit inner scope */ __pyx_v_new_csv_list = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
1718: # now write the new scv file
+1719: if destfile is None:
__Pyx_TraceLine(1719,0,__PYX_ERR(0, 1719, __pyx_L1_error)) __pyx_t_14 = (__pyx_v_destfile == Py_None); if (__pyx_t_14) { /* … */ }
+1720: destfile = f'{os.path.basename(csv_fn)}_to.en'
__Pyx_TraceLine(1720,0,__PYX_ERR(0, 1720, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_basename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_csv_fn}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_to_en); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_destfile, __pyx_t_3); __pyx_t_3 = 0;
1721:
+1722: destfile.replace('.csv', '')
__Pyx_TraceLine(1722,0,__PYX_ERR(0, 1722, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_destfile, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__92 = PyTuple_Pack(2, __pyx_kp_u_csv_2, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__92); __Pyx_GIVEREF(__pyx_tuple__92);
1723:
+1724: with open(f'{destfile}.csv', 'w', newline ='',encoding ='utf8') as csvf:
__Pyx_TraceLine(1724,0,__PYX_ERR(0, 1724, __pyx_L1_error)) /*with:*/ { __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_destfile, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_csv_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3)) __PYX_ERR(0, 1724, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_w); __Pyx_GIVEREF(__pyx_n_u_w); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_w)) __PYX_ERR(0, 1724, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_newline, __pyx_kp_u__22) < 0) __PYX_ERR(0, 1724, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 1724, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1724, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_17 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1724, __pyx_L60_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_csvf = __pyx_t_2; __pyx_t_2 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L69_try_end; __pyx_L64_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.convert_csvdata_from_fr_to_en", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_17, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 1724, __pyx_L66_except_error) __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_Pack(3, __pyx_t_17, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1724, __pyx_L66_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1724, __pyx_L66_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_14 < 0) __PYX_ERR(0, 1724, __pyx_L66_except_error) __pyx_t_13 = (!__pyx_t_14); if (unlikely(__pyx_t_13)) { __Pyx_GIVEREF(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_17, __pyx_t_3, __pyx_t_2); __pyx_t_17 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 1724, __pyx_L66_except_error) } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L65_exception_handled; } __pyx_L66_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L1_error; __pyx_L65_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); __pyx_L69_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_5) { __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } goto __pyx_L63; } __pyx_L63:; } goto __pyx_L73; __pyx_L60_error:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L1_error; __pyx_L73:; }
+1725: csv_writer = csv.writer(csvf, delimiter=',')
__Pyx_TraceLine(1725,0,__PYX_ERR(0, 1725, __pyx_L64_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_csv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1725, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_writer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1725, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1725, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_csvf); __Pyx_GIVEREF(__pyx_v_csvf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csvf)) __PYX_ERR(0, 1725, __pyx_L64_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1725, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_delimiter, __pyx_kp_u__48) < 0) __PYX_ERR(0, 1725, __pyx_L64_error) __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1725, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_csv_writer = __pyx_t_17; __pyx_t_17 = 0;
+1726: csv_writer.writerows(new_csv_list)
__Pyx_TraceLine(1726,0,__PYX_ERR(0, 1726, __pyx_L64_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_csv_writer, __pyx_n_s_writerows); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1726, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_new_csv_list}; __pyx_t_17 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1726, __pyx_L64_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
1727: # for row in new_csv_list:
1728: # csv_writer.writerow(row)
+1729: savepath = cpath(savepath , '__pme')
__Pyx_TraceLine(1729,0,__PYX_ERR(0, 1729, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cpath); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_17)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_17); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_v_savepath, __pyx_n_u_pme}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_savepath, __pyx_t_2); __pyx_t_2 = 0;
+1730: try :
__Pyx_TraceLine(1730,0,__PYX_ERR(0, 1730, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L79_try_end; __pyx_L74_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L76_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L75_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_7, __pyx_t_8); __pyx_L79_try_end:; }
+1731: shutil.move (f'{destfile}.csv', savepath)
__Pyx_TraceLine(1731,0,__PYX_ERR(0, 1731, __pyx_L74_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_shutil); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1731, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_move); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1731, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_destfile, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1731, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_3, __pyx_kp_u_csv_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1731, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_17))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_17); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_17, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_1, __pyx_v_savepath}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_17, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1731, __pyx_L74_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1732: except:pass
__Pyx_TraceLine(1732,0,__PYX_ERR(0, 1732, __pyx_L76_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L75_exception_handled; }
1733:
+1734: return new_csv_list
__Pyx_TraceLine(1734,0,__PYX_ERR(0, 1734, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_new_csv_list); __pyx_r = __pyx_v_new_csv_list; goto __pyx_L0;
1735:
+1736: def parse_md_data (pf , delimiter =':'):
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_60parse_md_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_60parse_md_data = {"parse_md_data", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_60parse_md_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_60parse_md_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_pf = 0;
PyObject *__pyx_v_delimiter = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("parse_md_data (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pf,&__pyx_n_s_delimiter,0};
PyObject* values[2] = {0,0};
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__32)));
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pf)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1736, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_delimiter);
if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1736, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "parse_md_data") < 0)) __PYX_ERR(0, 1736, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_pf = values[0];
__pyx_v_delimiter = values[1];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("parse_md_data", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 1736, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.parse_md_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_59parse_md_data(__pyx_self, __pyx_v_pf, __pyx_v_delimiter);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_59parse_md_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_pf, PyObject *__pyx_v_delimiter) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_5_parse_md_data *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_5_parse_md_data *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_5_parse_md_data(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_5_parse_md_data, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_5_parse_md_data *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 1736, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_v_pf = __pyx_v_pf;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_pf);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pf);
__pyx_cur_scope->__pyx_v_delimiter = __pyx_v_delimiter;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_delimiter);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_delimiter);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_61generator1, __pyx_codeobj__93, (PyObject *) __pyx_cur_scope, __pyx_n_s_parse_md_data, __pyx_n_s_parse_md_data, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 1736, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.parse_md_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_61generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("parse_md_data", 0);
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__93)
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1736, __pyx_L1_error)
/* … */
/* function exit code */
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_15);
__Pyx_AddTraceback("parse_md_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__393 = PyTuple_Pack(7, __pyx_n_s_pf, __pyx_n_s_delimiter, __pyx_n_s_f, __pyx_n_s_pdata, __pyx_n_s_row, __pyx_n_s_fr, __pyx_n_s_en); if (unlikely(!__pyx_tuple__393)) __PYX_ERR(0, 1736, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__393);
__Pyx_GIVEREF(__pyx_tuple__393);
/* … */
__Pyx_TraceLine(1736,0,__PYX_ERR(0, 1736, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_60parse_md_data, 0, __pyx_n_s_parse_md_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__93)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1736, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__390);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_md_data, __pyx_t_4) < 0) __PYX_ERR(0, 1736, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_codeobj__93 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__393, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parse_md_data, 1736, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__93)) __PYX_ERR(0, 1736, __pyx_L1_error)
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_5_parse_md_data {
PyObject_HEAD
PyObject *__pyx_v_delimiter;
PyObject *__pyx_v_en;
PyObject *__pyx_v_f;
PyObject *__pyx_v_fr;
PyObject *__pyx_v_pdata;
PyObject *__pyx_v_pf;
PyObject *__pyx_v_row;
PyObject *__pyx_t_0;
Py_ssize_t __pyx_t_1;
PyObject *(*__pyx_t_2)(PyObject *);
};
1737:
+1738: if not os.path.isfile (pf):
__Pyx_TraceLine(1738,0,__PYX_ERR(0, 1738, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isfile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_pf}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1738, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (!__pyx_t_5); if (unlikely(__pyx_t_6)) { /* … */ }
+1739: raise IOError( " Unable to detect the parser file. "
__Pyx_TraceLine(1739,0,__PYX_ERR(0, 1739, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_IOError, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1739, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1739, __pyx_L1_error) /* … */ __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_u_Unable_to_detect_the_parser_fil); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 1739, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__94); __Pyx_GIVEREF(__pyx_tuple__94);
1740: "Need a Path-like object ")
1741:
+1742: with open(pf, 'r', encoding ='utf8') as f:
__Pyx_TraceLine(1742,0,__PYX_ERR(0, 1742, __pyx_L1_error)) /*with:*/ { __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pf); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_pf)) __PYX_ERR(0, 1742, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_r); __Pyx_GIVEREF(__pyx_n_u_r); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_r)) __PYX_ERR(0, 1742, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 1742, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1742, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1742, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_f = __pyx_t_1; __pyx_t_1 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L14_try_end; __pyx_L9_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_md_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 1742, __pyx_L11_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_8 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1742, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, NULL); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1742, __pyx_L11_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6 < 0) __PYX_ERR(0, 1742, __pyx_L11_except_error) __pyx_t_5 = (!__pyx_t_6); if (unlikely(__pyx_t_5)) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_3, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 1742, __pyx_L11_except_error) } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L10_exception_handled; } __pyx_L11_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); goto __pyx_L1_error; __pyx_L10_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_L14_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_7) { __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } goto __pyx_L8; } __pyx_L8:; } goto __pyx_L18; __pyx_L5_error:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L1_error; __pyx_L18:; }
+1743: pdata = f.readlines ()
__Pyx_TraceLine(1743,0,__PYX_ERR(0, 1743, __pyx_L9_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_f, __pyx_n_s_readlines); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1743, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1743, __pyx_L9_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_pdata = __pyx_t_1; __pyx_t_1 = 0;
+1744: for row in pdata :
__Pyx_TraceLine(1744,0,__PYX_ERR(0, 1744, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_pdata)) { __Pyx_RaiseUnboundLocalError("pdata"); __PYX_ERR(0, 1744, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_pdata)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_pdata)) { __pyx_t_2 = __pyx_cur_scope->__pyx_v_pdata; __Pyx_INCREF(__pyx_t_2); __pyx_t_13 = 0; __pyx_t_14 = NULL; } else { __pyx_t_13 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_pdata); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1744, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_14)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1744, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_13); __Pyx_INCREF(__pyx_t_3); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 1744, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1744, __pyx_L1_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_13); __Pyx_INCREF(__pyx_t_3); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 1744, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_14(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1744, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(1744,0,__PYX_ERR(0, 1744, __pyx_L1_error)) __pyx_L19_continue:; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+1745: if row in ('\n', ' '):
__Pyx_TraceLine(1745,0,__PYX_ERR(0, 1745, __pyx_L1_error)) __Pyx_INCREF(__pyx_cur_scope->__pyx_v_row); __pyx_t_3 = __pyx_cur_scope->__pyx_v_row; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u__11, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1745, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L22_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u__14, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1745, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L22_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __pyx_t_5; if (__pyx_t_6) { /* … */ }
+1746: continue
__Pyx_TraceLine(1746,0,__PYX_ERR(0, 1746, __pyx_L1_error)) goto __pyx_L19_continue;
+1747: fr, en = row.strip().split(delimiter)
__Pyx_TraceLine(1747,0,__PYX_ERR(0, 1747, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_row, __pyx_n_s_strip); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_15 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_split); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_delimiter}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1747, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_15 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_15); index = 0; __pyx_t_8 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_8)) goto __pyx_L24_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); index = 1; __pyx_t_1 = __pyx_t_16(__pyx_t_15); if (unlikely(!__pyx_t_1)) goto __pyx_L24_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 2) < 0) __PYX_ERR(0, 1747, __pyx_L1_error) __pyx_t_16 = NULL; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L25_unpacking_done; __pyx_L24_unpacking_failed:; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_16 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1747, __pyx_L1_error) __pyx_L25_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_fr); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_fr, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_en); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_en, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
+1748: fr = sanitize_unicode_string(fr)
__Pyx_TraceLine(1748,0,__PYX_ERR(0, 1748, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_sanitize_unicode_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_fr}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fr); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_fr, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
+1749: en = en.strip()
__Pyx_TraceLine(1749,0,__PYX_ERR(0, 1749, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_en, __pyx_n_s_strip); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_en); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_en, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
1750: # if capilize, the "I" inside the
1751: #text should be in lowercase
1752: # it is better to upper the first
1753: # character after striping the whole
1754: # string
+1755: en = list(en)
__Pyx_TraceLine(1755,0,__PYX_ERR(0, 1755, __pyx_L1_error)) __pyx_t_3 = PySequence_List(__pyx_cur_scope->__pyx_v_en); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_en); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_en, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
+1756: en[0] = en[0].upper()
__Pyx_TraceLine(1756,0,__PYX_ERR(0, 1756, __pyx_L1_error)) __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_en, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_upper); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1756, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if (unlikely((__Pyx_SetItemInt(__pyx_cur_scope->__pyx_v_en, 0, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0))) __PYX_ERR(0, 1756, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1757: en = "".join(en)
__Pyx_TraceLine(1757,0,__PYX_ERR(0, 1757, __pyx_L1_error)) __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__22, __pyx_cur_scope->__pyx_v_en); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_en); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_en, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
1758:
+1759: yield fr, en
__Pyx_TraceLine(1759,0,__PYX_ERR(0, 1759, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fr); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_fr)) __PYX_ERR(0, 1759, __pyx_L1_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_en); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_en); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_en)) __PYX_ERR(0, 1759, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; __Pyx_XGIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; __pyx_cur_scope->__pyx_t_1 = __pyx_t_13; __pyx_cur_scope->__pyx_t_2 = __pyx_t_14; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L26_resume_from_yield:; __pyx_t_2 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_2); __pyx_t_13 = __pyx_cur_scope->__pyx_t_1; __pyx_t_14 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1759, __pyx_L1_error)
1760:
+1761: def sanitize_unicode_string (str_) :
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_63sanitize_unicode_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_62sanitize_unicode_string, " Replace all spaces and remove all french accents characters.\n \n :Example:\n >>> from gofast.tools.coreutils import sanitize_unicode_string \n >>> sentence ='Nos clients sont extr\303\252mement satisfaits '\n 'de la qualit\303\251 du service fourni. En outre Nos clients '\n 'rach\303\250tent frequemment nos \"services\".'\n >>> sanitize_unicode_string (sentence)\n ... 'nosclientssontextrmementsatisfaitsdelaqualitduservice'\n 'fournienoutrenosclientsrachtentfrequemmentnosservices'\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_63sanitize_unicode_string = {"sanitize_unicode_string", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_63sanitize_unicode_string, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_62sanitize_unicode_string}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_63sanitize_unicode_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_str_ = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sanitize_unicode_string (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_str,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_str)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1761, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "sanitize_unicode_string") < 0)) __PYX_ERR(0, 1761, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_str_ = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sanitize_unicode_string", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1761, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.sanitize_unicode_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_62sanitize_unicode_string(__pyx_self, __pyx_v_str_); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_62sanitize_unicode_string(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_str_) { PyObject *__pyx_v_sp_re = NULL; PyObject *__pyx_v_e_re = NULL; PyObject *__pyx_v_a_re = NULL; PyObject *__pyx_v_cobj = NULL; PyObject *__pyx_v_repl = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__95) __Pyx_TraceCall("sanitize_unicode_string", __pyx_f[0], 1761, 0, __PYX_ERR(0, 1761, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_str_); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.sanitize_unicode_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_sp_re); __Pyx_XDECREF(__pyx_v_e_re); __Pyx_XDECREF(__pyx_v_a_re); __Pyx_XDECREF(__pyx_v_cobj); __Pyx_XDECREF(__pyx_v_repl); __Pyx_XDECREF(__pyx_v_str_); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__394 = PyTuple_Pack(6, __pyx_n_s_str, __pyx_n_s_sp_re, __pyx_n_s_e_re, __pyx_n_s_a_re, __pyx_n_s_cobj, __pyx_n_s_repl); if (unlikely(!__pyx_tuple__394)) __PYX_ERR(0, 1761, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__394); __Pyx_GIVEREF(__pyx_tuple__394); /* … */ __Pyx_TraceLine(1761,0,__PYX_ERR(0, 1761, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_63sanitize_unicode_string, 0, __pyx_n_s_sanitize_unicode_string, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__95)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sanitize_unicode_string, __pyx_t_4) < 0) __PYX_ERR(0, 1761, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__95 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__394, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_sanitize_unicode_string, 1761, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__95)) __PYX_ERR(0, 1761, __pyx_L1_error)
1762: """ Replace all spaces and remove all french accents characters.
1763:
1764: :Example:
1765: >>> from gofast.tools.coreutils import sanitize_unicode_string
1766: >>> sentence ='Nos clients sont extrêmement satisfaits '
1767: 'de la qualité du service fourni. En outre Nos clients '
1768: 'rachètent frequemment nos "services".'
1769: >>> sanitize_unicode_string (sentence)
1770: ... 'nosclientssontextrmementsatisfaitsdelaqualitduservice'
1771: 'fournienoutrenosclientsrachtentfrequemmentnosservices'
1772: """
+1773: sp_re = re.compile (r"[.'()-\\/’]")
__Pyx_TraceLine(1773,0,__PYX_ERR(0, 1773, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1773, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1773, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_u__96}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1773, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_sp_re = __pyx_t_1; __pyx_t_1 = 0;
+1774: e_re = re.compile(r'[éèê]')
__Pyx_TraceLine(1774,0,__PYX_ERR(0, 1774, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_kp_u__97}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_e_re = __pyx_t_1; __pyx_t_1 = 0;
+1775: a_re= re.compile(r'[àâ]')
__Pyx_TraceLine(1775,0,__PYX_ERR(0, 1775, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1775, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1775, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_u__98}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1775, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_a_re = __pyx_t_1; __pyx_t_1 = 0;
1776:
+1777: str_= re.sub('\s+', '', str_.strip().lower())
__Pyx_TraceLine(1777,0,__PYX_ERR(0, 1777, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_str_, __pyx_n_s_strip); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_lower); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_kp_u_s_3, __pyx_kp_u__22, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1777, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_str_, __pyx_t_1); __pyx_t_1 = 0;
1778:
+1779: for cobj , repl in zip ( (sp_re, e_re, a_re),
__Pyx_TraceLine(1779,0,__PYX_ERR(0, 1779, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_sp_re); __Pyx_GIVEREF(__pyx_v_sp_re); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sp_re)) __PYX_ERR(0, 1779, __pyx_L1_error); __Pyx_INCREF(__pyx_v_e_re); __Pyx_GIVEREF(__pyx_v_e_re); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_e_re)) __PYX_ERR(0, 1779, __pyx_L1_error); __Pyx_INCREF(__pyx_v_a_re); __Pyx_GIVEREF(__pyx_v_a_re); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_a_re)) __PYX_ERR(0, 1779, __pyx_L1_error); /* … */ __Pyx_TraceLine(1780,0,__PYX_ERR(0, 1780, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 1779, __pyx_L1_error); __Pyx_INCREF(__pyx_tuple__99); __Pyx_GIVEREF(__pyx_tuple__99); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_tuple__99)) __PYX_ERR(0, 1779, __pyx_L1_error); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1779,0,__PYX_ERR(0, 1779, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1779, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1779, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1779, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1779, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 1779, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1779, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1779, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1779, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_6 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_5), 2) < 0) __PYX_ERR(0, 1779, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1779, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_cobj, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_repl, __pyx_t_6); __pyx_t_6 = 0; /* … */ __Pyx_TraceLine(1779,0,__PYX_ERR(0, 1779, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1780: ("", 'e', 'a')):
__pyx_tuple__99 = PyTuple_Pack(3, __pyx_kp_u__22, __pyx_n_u_e, __pyx_n_u_a); if (unlikely(!__pyx_tuple__99)) __PYX_ERR(0, 1780, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__99); __Pyx_GIVEREF(__pyx_tuple__99);
+1781: str_ = cobj.sub(repl, str_)
__Pyx_TraceLine(1781,0,__PYX_ERR(0, 1781, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_cobj, __pyx_n_s_sub); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_repl, __pyx_v_str_}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF_SET(__pyx_v_str_, __pyx_t_1); __pyx_t_1 = 0;
1782:
+1783: return str_
__Pyx_TraceLine(1783,0,__PYX_ERR(0, 1783, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_str_); __pyx_r = __pyx_v_str_; goto __pyx_L0;
1784:
+1785: def read_main (csv_fn , pf , delimiter =':',
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_65read_main(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_65read_main = {"read_main", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_65read_main, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_65read_main(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_csv_fn = 0;
PyObject *__pyx_v_pf = 0;
PyObject *__pyx_v_delimiter = 0;
PyObject *__pyx_v_destfile = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("read_main (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_csv_fn,&__pyx_n_s_pf,&__pyx_n_s_delimiter,&__pyx_n_s_destfile,0};
PyObject* values[4] = {0,0,0,0};
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__32)));
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u_pme_en_csv)));
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_csv_fn)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1785, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pf)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1785, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("read_main", 0, 2, 4, 1); __PYX_ERR(0, 1785, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_delimiter);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1785, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_destfile);
if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1785, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "read_main") < 0)) __PYX_ERR(0, 1785, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_csv_fn = values[0];
__pyx_v_pf = values[1];
__pyx_v_delimiter = values[2];
__pyx_v_destfile = values[3];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("read_main", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 1785, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.read_main", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_64read_main(__pyx_self, __pyx_v_csv_fn, __pyx_v_pf, __pyx_v_delimiter, __pyx_v_destfile);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_64read_main(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csv_fn, PyObject *__pyx_v_pf, PyObject *__pyx_v_delimiter, PyObject *__pyx_v_destfile) {
PyObject *__pyx_v_parser_data = NULL;
PyObject *__pyx_v_parser_dict = NULL;
PyObject *__pyx_v_csv_f = NULL;
PyObject *__pyx_v_csv_reader = NULL;
PyObject *__pyx_v_csv_data = NULL;
PyObject *__pyx_v_ix = NULL;
PyObject *__pyx_v_csv_1b = NULL;
PyObject *__pyx_v_csv_2b = NULL;
PyObject *__pyx_v_csv_1bb = NULL;
PyObject *__pyx_v_copyd = NULL;
PyObject *__pyx_v_is_missing = NULL;
PyObject *__pyx_v_ii = NULL;
PyObject *__pyx_v_rowline = NULL;
PyObject *__pyx_v_jj = NULL;
PyObject *__pyx_v_row = NULL;
PyObject *__pyx_v_new_csv_list = NULL;
PyObject *__pyx_v_df = NULL;
PyObject *__pyx_v_key = NULL;
PyObject *__pyx_v_value = NULL;
PyObject *__pyx_9genexpr24__pyx_v_row = NULL;
PyObject *__pyx_9genexpr25__pyx_v_row = NULL;
PyObject *__pyx_9genexpr26__pyx_v_row = NULL;
PyObject *__pyx_9genexpr27__pyx_v_r1 = NULL;
PyObject *__pyx_9genexpr27__pyx_v_r2 = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__100)
__Pyx_TraceCall("read_main", __pyx_f[0], 1785, 0, __PYX_ERR(0, 1785, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_17);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_XDECREF(__pyx_t_19);
__Pyx_AddTraceback("gofast.tools.coreutils.read_main", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_parser_data);
__Pyx_XDECREF(__pyx_v_parser_dict);
__Pyx_XDECREF(__pyx_v_csv_f);
__Pyx_XDECREF(__pyx_v_csv_reader);
__Pyx_XDECREF(__pyx_v_csv_data);
__Pyx_XDECREF(__pyx_v_ix);
__Pyx_XDECREF(__pyx_v_csv_1b);
__Pyx_XDECREF(__pyx_v_csv_2b);
__Pyx_XDECREF(__pyx_v_csv_1bb);
__Pyx_XDECREF(__pyx_v_copyd);
__Pyx_XDECREF(__pyx_v_is_missing);
__Pyx_XDECREF(__pyx_v_ii);
__Pyx_XDECREF(__pyx_v_rowline);
__Pyx_XDECREF(__pyx_v_jj);
__Pyx_XDECREF(__pyx_v_row);
__Pyx_XDECREF(__pyx_v_new_csv_list);
__Pyx_XDECREF(__pyx_v_df);
__Pyx_XDECREF(__pyx_v_key);
__Pyx_XDECREF(__pyx_v_value);
__Pyx_XDECREF(__pyx_9genexpr24__pyx_v_row);
__Pyx_XDECREF(__pyx_9genexpr25__pyx_v_row);
__Pyx_XDECREF(__pyx_9genexpr26__pyx_v_row);
__Pyx_XDECREF(__pyx_9genexpr27__pyx_v_r1);
__Pyx_XDECREF(__pyx_9genexpr27__pyx_v_r2);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__395 = PyTuple_Pack(28, __pyx_n_s_csv_fn, __pyx_n_s_pf, __pyx_n_s_delimiter, __pyx_n_s_destfile, __pyx_n_s_parser_data, __pyx_n_s_parser_dict, __pyx_n_s_csv_f, __pyx_n_s_csv_reader, __pyx_n_s_csv_data, __pyx_n_s_ix, __pyx_n_s_csv_1b, __pyx_n_s_csv_2b, __pyx_n_s_csv_1bb, __pyx_n_s_copyd, __pyx_n_s_is_missing, __pyx_n_s_ii, __pyx_n_s_rowline, __pyx_n_s_jj, __pyx_n_s_row, __pyx_n_s_new_csv_list, __pyx_n_s_df, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_row, __pyx_n_s_row, __pyx_n_s_row, __pyx_n_s_r1, __pyx_n_s_r2); if (unlikely(!__pyx_tuple__395)) __PYX_ERR(0, 1785, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__395);
__Pyx_GIVEREF(__pyx_tuple__395);
__pyx_codeobj__100 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 28, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__395, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_read_main, 1785, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__100)) __PYX_ERR(0, 1785, __pyx_L1_error)
/* … */
__Pyx_TraceLine(1785,0,__PYX_ERR(0, 1785, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_65read_main, 0, __pyx_n_s_read_main, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__100)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1785, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__396);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_main, __pyx_t_4) < 0) __PYX_ERR(0, 1785, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_tuple__396 = PyTuple_Pack(2, ((PyObject*)__pyx_kp_u__32), ((PyObject*)__pyx_kp_u_pme_en_csv)); if (unlikely(!__pyx_tuple__396)) __PYX_ERR(0, 1785, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__396);
__Pyx_GIVEREF(__pyx_tuple__396);
1786: destfile ='pme.en.csv') :
1787:
+1788: parser_data = list(parse_md_data(pf, delimiter) )
__Pyx_TraceLine(1788,0,__PYX_ERR(0, 1788, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_parse_md_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_pf, __pyx_v_delimiter}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_parser_data = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+1789: parser_dict =dict(parser_data)
__Pyx_TraceLine(1789,0,__PYX_ERR(0, 1789, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_v_parser_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_parser_dict = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
1790:
+1791: with open (csv_fn, 'r', encoding ='utf8') as csv_f :
__Pyx_TraceLine(1791,0,__PYX_ERR(0, 1791, __pyx_L1_error)) /*with:*/ { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_csv_fn); __Pyx_GIVEREF(__pyx_v_csv_fn); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csv_fn)) __PYX_ERR(0, 1791, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_r); __Pyx_GIVEREF(__pyx_n_u_r); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_r)) __PYX_ERR(0, 1791, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 1791, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1791, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1791, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __pyx_v_csv_f = __pyx_t_2; __pyx_t_2 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.read_main", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 1791, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1791, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1791, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_13 < 0) __PYX_ERR(0, 1791, __pyx_L9_except_error) __pyx_t_14 = (!__pyx_t_13); if (unlikely(__pyx_t_14)) { __Pyx_GIVEREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; __PYX_ERR(0, 1791, __pyx_L9_except_error) } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_L12_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } goto __pyx_L6; } __pyx_L6:; } goto __pyx_L23; __pyx_L3_error:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L1_error; __pyx_L23:; }
+1792: csv_reader = csv.reader(csv_f)
__Pyx_TraceLine(1792,0,__PYX_ERR(0, 1792, __pyx_L7_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_csv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1792, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1792, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_csv_f}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1792, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_csv_reader = __pyx_t_2; __pyx_t_2 = 0;
+1793: csv_data =[ row for row in csv_reader]
__Pyx_TraceLine(1793,0,__PYX_ERR(0, 1793, __pyx_L7_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1793, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_v_csv_reader)) || PyTuple_CheckExact(__pyx_v_csv_reader)) { __pyx_t_1 = __pyx_v_csv_reader; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_csv_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1793, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1793, __pyx_L15_error) } for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1793, __pyx_L15_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1793, __pyx_L15_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1793, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1793, __pyx_L15_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1793, __pyx_L15_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1793, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1793, __pyx_L15_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_9genexpr24__pyx_v_row, __pyx_t_3); __pyx_t_3 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_9genexpr24__pyx_v_row))) __PYX_ERR(0, 1793, __pyx_L15_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr24__pyx_v_row); __pyx_9genexpr24__pyx_v_row = 0; goto __pyx_L19_exit_scope; __pyx_L15_error:; __Pyx_XDECREF(__pyx_9genexpr24__pyx_v_row); __pyx_9genexpr24__pyx_v_row = 0; goto __pyx_L7_error; __pyx_L19_exit_scope:; } /* exit inner scope */ __pyx_v_csv_data = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
1794:
1795: # get the index of the last substring row
1796: # and separate block into two from "Industry_type"
+1797: ix = csv_data [0].index ('Industry_type')
__Pyx_TraceLine(1797,0,__PYX_ERR(0, 1797, __pyx_L1_error)) if (unlikely(!__pyx_v_csv_data)) { __Pyx_RaiseUnboundLocalError("csv_data"); __PYX_ERR(0, 1797, __pyx_L1_error) } __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_csv_data, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_n_u_Industry_type}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_ix = __pyx_t_3; __pyx_t_3 = 0;
1798:
+1799: csv_1b = [row [:ix +1] for row in csv_data]
__Pyx_TraceLine(1799,0,__PYX_ERR(0, 1799, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1799, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_v_csv_data)) { __Pyx_RaiseUnboundLocalError("csv_data"); __PYX_ERR(0, 1799, __pyx_L26_error) } __pyx_t_2 = __pyx_v_csv_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1799, __pyx_L26_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1799, __pyx_L26_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1799, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_9genexpr25__pyx_v_row, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ix, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1799, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_9genexpr25__pyx_v_row, 0, 0, NULL, &__pyx_t_1, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1799, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 1799, __pyx_L26_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr25__pyx_v_row); __pyx_9genexpr25__pyx_v_row = 0; goto __pyx_L30_exit_scope; __pyx_L26_error:; __Pyx_XDECREF(__pyx_9genexpr25__pyx_v_row); __pyx_9genexpr25__pyx_v_row = 0; goto __pyx_L1_error; __pyx_L30_exit_scope:; } /* exit inner scope */ __pyx_v_csv_1b = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+1800: csv_2b =[row [ix+1:] for row in csv_data ]
__Pyx_TraceLine(1800,0,__PYX_ERR(0, 1800, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1800, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_v_csv_data)) { __Pyx_RaiseUnboundLocalError("csv_data"); __PYX_ERR(0, 1800, __pyx_L33_error) } __pyx_t_2 = __pyx_v_csv_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1800, __pyx_L33_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1800, __pyx_L33_error) #else __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1800, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_XDECREF_SET(__pyx_9genexpr26__pyx_v_row, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_AddObjC(__pyx_v_ix, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1800, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_9genexpr26__pyx_v_row, 0, 0, &__pyx_t_6, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1800, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1800, __pyx_L33_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr26__pyx_v_row); __pyx_9genexpr26__pyx_v_row = 0; goto __pyx_L37_exit_scope; __pyx_L33_error:; __Pyx_XDECREF(__pyx_9genexpr26__pyx_v_row); __pyx_9genexpr26__pyx_v_row = 0; goto __pyx_L1_error; __pyx_L37_exit_scope:; } /* exit inner scope */ __pyx_v_csv_2b = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
1801: # make a copy of csv_1b
+1802: csv_1bb= copy.deepcopy(csv_1b)
__Pyx_TraceLine(1802,0,__PYX_ERR(0, 1802, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_csv_1b}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_csv_1bb = __pyx_t_3; __pyx_t_3 = 0;
+1803: copyd = copy.deepcopy(csv_1bb); is_missing =list()
__Pyx_TraceLine(1803,0,__PYX_ERR(0, 1803, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_csv_1bb}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_copyd = __pyx_t_3; __pyx_t_3 = 0; __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_is_missing = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
1804:
1805: # skip the first two rows
+1806: for ii, rowline in enumerate( csv_1bb[3:]) :
__Pyx_TraceLine(1806,0,__PYX_ERR(0, 1806, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_3 = __pyx_int_0; __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_csv_1bb, 3, 0, NULL, NULL, &__pyx_slice__86, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1806, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1806, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1806, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1806, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1806, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1806, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_rowline, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_3); __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(1806,0,__PYX_ERR(0, 1806, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1807: for jj , row in enumerate(rowline):
__Pyx_TraceLine(1807,0,__PYX_ERR(0, 1807, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_2 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_rowline)) || PyTuple_CheckExact(__pyx_v_rowline)) { __pyx_t_6 = __pyx_v_rowline; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; __pyx_t_16 = NULL; } else { __pyx_t_15 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_rowline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1807, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_16)) { if (likely(PyList_CheckExact(__pyx_t_6))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1807, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_17 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_17); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 1807, __pyx_L1_error) #else __pyx_t_17 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1807, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_17 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_17); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 1807, __pyx_L1_error) #else __pyx_t_17 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); #endif } } else { __pyx_t_17 = __pyx_t_16(__pyx_t_6); if (unlikely(!__pyx_t_17)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1807, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_17); } __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_17); __pyx_t_17 = 0; __Pyx_INCREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_jj, __pyx_t_2); __pyx_t_17 = __Pyx_PyInt_AddObjC(__pyx_t_2, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_17; __pyx_t_17 = 0; /* … */ __Pyx_TraceLine(1807,0,__PYX_ERR(0, 1807, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1808: row = row.strip()
__Pyx_TraceLine(1808,0,__PYX_ERR(0, 1808, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_row, __pyx_n_s_strip); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_18))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_19, NULL}; __pyx_t_17 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1808, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __Pyx_DECREF_SET(__pyx_v_row, __pyx_t_17); __pyx_t_17 = 0;
+1809: row = sanitize_unicode_string(row )
__Pyx_TraceLine(1809,0,__PYX_ERR(0, 1809, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_sanitize_unicode_string); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_v_row}; __pyx_t_17 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __Pyx_DECREF_SET(__pyx_v_row, __pyx_t_17); __pyx_t_17 = 0;
+1810: csv_1bb[3:][ii][jj] = row
__Pyx_TraceLine(1810,0,__PYX_ERR(0, 1810, __pyx_L1_error)) __pyx_t_17 = __Pyx_PyObject_GetSlice(__pyx_v_csv_1bb, 3, 0, NULL, NULL, &__pyx_slice__86, 1, 0, 1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __Pyx_PyObject_GetItem(__pyx_t_17, __pyx_v_ii); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely((PyObject_SetItem(__pyx_t_18, __pyx_v_jj, __pyx_v_row) < 0))) __PYX_ERR(0, 1810, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
1811:
1812: #collect the missing values
+1813: for ii, rowline in enumerate( csv_1bb[3:]) :
__Pyx_TraceLine(1813,0,__PYX_ERR(0, 1813, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_3 = __pyx_int_0; __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_csv_1bb, 3, 0, NULL, NULL, &__pyx_slice__86, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1813, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1813, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1813, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1813, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1813, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1813, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_rowline, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_3); __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(1813,0,__PYX_ERR(0, 1813, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1814: for jj , row in enumerate(rowline):
__Pyx_TraceLine(1814,0,__PYX_ERR(0, 1814, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_rowline)) || PyTuple_CheckExact(__pyx_v_rowline)) { __pyx_t_6 = __pyx_v_rowline; __Pyx_INCREF(__pyx_t_6); __pyx_t_15 = 0; __pyx_t_16 = NULL; } else { __pyx_t_15 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_rowline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1814, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_16)) { if (likely(PyList_CheckExact(__pyx_t_6))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1814, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_18 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_18); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 1814, __pyx_L1_error) #else __pyx_t_18 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1814, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_18 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_15); __Pyx_INCREF(__pyx_t_18); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 1814, __pyx_L1_error) #else __pyx_t_18 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); #endif } } else { __pyx_t_18 = __pyx_t_16(__pyx_t_6); if (unlikely(!__pyx_t_18)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1814, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_18); } __Pyx_XDECREF_SET(__pyx_v_row, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_jj, __pyx_t_1); __pyx_t_18 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1814, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_18; __pyx_t_18 = 0; /* … */ __Pyx_TraceLine(1814,0,__PYX_ERR(0, 1814, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1815: if row not in parser_dict.keys():
__Pyx_TraceLine(1815,0,__PYX_ERR(0, 1815, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyDict_Keys(__pyx_v_parser_dict); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1815, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_14 = (__Pyx_PySequence_ContainsTF(__pyx_v_row, __pyx_t_18, Py_NE)); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 1815, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__pyx_t_14) { /* … */ }
+1816: is_missing.append(copyd[3:][ii][jj])
__Pyx_TraceLine(1816,0,__PYX_ERR(0, 1816, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyObject_GetSlice(__pyx_v_copyd, 3, 0, NULL, NULL, &__pyx_slice__86, 1, 0, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = __Pyx_PyObject_GetItem(__pyx_t_18, __pyx_v_ii); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyObject_GetItem(__pyx_t_17, __pyx_v_jj); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_is_missing, __pyx_t_18); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 1816, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+1817: is_missing = list(set(is_missing))
__Pyx_TraceLine(1817,0,__PYX_ERR(0, 1817, __pyx_L1_error)) __pyx_t_3 = PySet_New(__pyx_v_is_missing); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1817, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1817, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_is_missing, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
1818:
1819: # merge the prior two blocks and build the dataframe
+1820: new_csv_list = [r1 + r2 for r1, r2 in zip(csv_1bb, csv_2b )]
__Pyx_TraceLine(1820,0,__PYX_ERR(0, 1820, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_csv_1bb); __Pyx_GIVEREF(__pyx_v_csv_1bb); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_csv_1bb)) __PYX_ERR(0, 1820, __pyx_L53_error); __Pyx_INCREF(__pyx_v_csv_2b); __Pyx_GIVEREF(__pyx_v_csv_2b); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_csv_2b)) __PYX_ERR(0, 1820, __pyx_L53_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1820, __pyx_L53_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1820, __pyx_L53_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1820, __pyx_L53_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1820, __pyx_L53_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 1820, __pyx_L53_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1820, __pyx_L53_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1820, __pyx_L53_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_18 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_18 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_18); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_18 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_18); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_17 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_21 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_17); index = 0; __pyx_t_6 = __pyx_t_21(__pyx_t_17); if (unlikely(!__pyx_t_6)) goto __pyx_L56_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_18 = __pyx_t_21(__pyx_t_17); if (unlikely(!__pyx_t_18)) goto __pyx_L56_unpacking_failed; __Pyx_GOTREF(__pyx_t_18); if (__Pyx_IternextUnpackEndCheck(__pyx_t_21(__pyx_t_17), 2) < 0) __PYX_ERR(0, 1820, __pyx_L53_error) __pyx_t_21 = NULL; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; goto __pyx_L57_unpacking_done; __pyx_L56_unpacking_failed:; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_t_21 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 1820, __pyx_L53_error) __pyx_L57_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_9genexpr27__pyx_v_r1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_9genexpr27__pyx_v_r2, __pyx_t_18); __pyx_t_18 = 0; __pyx_t_1 = PyNumber_Add(__pyx_9genexpr27__pyx_v_r1, __pyx_9genexpr27__pyx_v_r2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 1820, __pyx_L53_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr27__pyx_v_r1); __pyx_9genexpr27__pyx_v_r1 = 0; __Pyx_XDECREF(__pyx_9genexpr27__pyx_v_r2); __pyx_9genexpr27__pyx_v_r2 = 0; goto __pyx_L59_exit_scope; __pyx_L53_error:; __Pyx_XDECREF(__pyx_9genexpr27__pyx_v_r1); __pyx_9genexpr27__pyx_v_r1 = 0; __Pyx_XDECREF(__pyx_9genexpr27__pyx_v_r2); __pyx_9genexpr27__pyx_v_r2 = 0; goto __pyx_L1_error; __pyx_L59_exit_scope:; } /* exit inner scope */ __pyx_v_new_csv_list = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+1821: df = pd.DataFrame (
__Pyx_TraceLine(1821,0,__PYX_ERR(0, 1821, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(1821,0,__PYX_ERR(0, 1821, __pyx_L1_error)) __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2)) __PYX_ERR(0, 1821, __pyx_L1_error); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(1821,0,__PYX_ERR(0, 1821, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_18, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_df = __pyx_t_1; __pyx_t_1 = 0;
+1822: np.array(new_csv_list [1:]),
__Pyx_TraceLine(1822,0,__PYX_ERR(0, 1822, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_new_csv_list, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_1}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; }
+1823: columns =new_csv_list [0]
__Pyx_TraceLine(1823,0,__PYX_ERR(0, 1823, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_new_csv_list, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1823, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_t_1) < 0) __PYX_ERR(0, 1823, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1824: )
+1825: for key, value in parser_dict.items():
__Pyx_TraceLine(1825,0,__PYX_ERR(0, 1825, __pyx_L1_error)) __pyx_t_10 = 0; __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_parser_dict, 1, __pyx_n_s_items, (&__pyx_t_15), (&__pyx_t_4)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; while (1) { __pyx_t_22 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_15, &__pyx_t_10, &__pyx_t_2, &__pyx_t_18, NULL, __pyx_t_4); if (unlikely(__pyx_t_22 == 0)) break; if (unlikely(__pyx_t_22 == -1)) __PYX_ERR(0, 1825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_18); __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_18); __pyx_t_18 = 0;
1826: # perform operation in place and return None
+1827: df.replace (key, value, inplace =True )
__Pyx_TraceLine(1827,0,__PYX_ERR(0, 1827, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_replace); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_key); __Pyx_GIVEREF(__pyx_v_key); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key)) __PYX_ERR(0, 1827, __pyx_L1_error); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value)) __PYX_ERR(0, 1827, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 1827, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1827, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1828:
1829:
+1830: df.to_csv (destfile)
__Pyx_TraceLine(1830,0,__PYX_ERR(0, 1830, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_to_csv); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_destfile}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1831: return df , is_missing
__Pyx_TraceLine(1831,0,__PYX_ERR(0, 1831, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1831, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_df); __Pyx_GIVEREF(__pyx_v_df); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_df)) __PYX_ERR(0, 1831, __pyx_L1_error); __Pyx_INCREF(__pyx_v_is_missing); __Pyx_GIVEREF(__pyx_v_is_missing); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_is_missing)) __PYX_ERR(0, 1831, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1832:
1833:
+1834: def _isin (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_67_isin(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_66_isin, " Check whether the subset array `subcz` is in `cz` array. \n \n :param arr: Array-like - Array of item elements \n :param subarr: Array-like, float - Subset array containing a subset items.\n :param return_mask: bool, return the mask where the element is in `arr`.\n \n :return: True if items in test array `subarr` are in array `arr`. \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_67_isin = {"_isin", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_67_isin, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_66_isin}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_67_isin(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_subarr = 0; PyObject *__pyx_v_return_mask = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_isin (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_subarr,&__pyx_n_s_return_mask,0}; PyObject* values[3] = {0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_66_isin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_subarr, PyObject *__pyx_v_return_mask) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__101) __Pyx_TraceCall("_isin", __pyx_f[0], 1834, 0, __PYX_ERR(0, 1834, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_arr); __Pyx_INCREF(__pyx_v_subarr); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils._isin", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_arr); __Pyx_XDECREF(__pyx_v_subarr); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__397 = PyTuple_Pack(3, __pyx_n_s_arr, __pyx_n_s_subarr, __pyx_n_s_return_mask); if (unlikely(!__pyx_tuple__397)) __PYX_ERR(0, 1834, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__397); __Pyx_GIVEREF(__pyx_tuple__397); /* … */ __Pyx_TraceLine(1834,0,__PYX_ERR(0, 1834, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_arr, __pyx_kp_s_Union_ArrayLike_List_float) < 0) __PYX_ERR(0, 1834, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_subarr, __pyx_kp_s_Union__Sub_ArrayLike__Sub_List_f) < 0) __PYX_ERR(0, 1834, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return_mask, __pyx_n_s_bool) < 0) __PYX_ERR(0, 1834, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 1834, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_67_isin, 0, __pyx_n_s_isin_2, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__101)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__384); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_isin_2, __pyx_t_5) < 0) __PYX_ERR(0, 1834, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__101 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__397, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_isin_2, 1834, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__101)) __PYX_ERR(0, 1834, __pyx_L1_error)
1835: arr: Union [ArrayLike, List [float]] ,
1836: subarr:Union[ _Sub [ArrayLike] , _Sub[List[float]] ,float],
+1837: return_mask:bool=False,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1834, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_subarr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1834, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_isin", 0, 2, 3, 1); __PYX_ERR(0, 1834, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_mask); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1834, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_isin") < 0)) __PYX_ERR(0, 1834, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_subarr = values[1]; __pyx_v_return_mask = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_isin", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 1834, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._isin", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_66_isin(__pyx_self, __pyx_v_arr, __pyx_v_subarr, __pyx_v_return_mask);
1838: ) -> bool :
1839: """ Check whether the subset array `subcz` is in `cz` array.
1840:
1841: :param arr: Array-like - Array of item elements
1842: :param subarr: Array-like, float - Subset array containing a subset items.
1843: :param return_mask: bool, return the mask where the element is in `arr`.
1844:
1845: :return: True if items in test array `subarr` are in array `arr`.
1846:
1847: """
+1848: arr = np.array (arr ); subarr = np.array(subarr )
__Pyx_TraceLine(1848,0,__PYX_ERR(0, 1848, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_subarr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1848, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_subarr, __pyx_t_1); __pyx_t_1 = 0;
1849:
+1850: return (True if True in np.isin (arr, subarr) else False
__Pyx_TraceLine(1850,0,__PYX_ERR(0, 1850, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); /* … */ __Pyx_TraceLine(1850,0,__PYX_ERR(0, 1850, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_v_arr, __pyx_v_subarr}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1850, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_5 = (__Pyx_PySequence_ContainsTF(Py_True, __pyx_t_3, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1850, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { __Pyx_INCREF(Py_True); __pyx_t_2 = Py_True; } else { __Pyx_INCREF(Py_False); __pyx_t_2 = Py_False; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } else {
+1851: ) if not return_mask else np.isin (arr, subarr)
__Pyx_TraceLine(1851,0,__PYX_ERR(0, 1851, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_return_mask); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1851, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ __Pyx_TraceLine(1851,0,__PYX_ERR(0, 1851, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_arr, __pyx_v_subarr}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1852:
+1853: def _assert_all_types (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_69_assert_all_types(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_68_assert_all_types, " Quick assertion of object type. Raises a `TypeError` if wrong type \n is passed as an argument. For polishing the error message, one can add \n the object name `objname` for specifying the object that raises errors \n for letting the users to be aware of the reason of failure."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_69_assert_all_types = {"_assert_all_types", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_69_assert_all_types, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_68_assert_all_types}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_69_assert_all_types(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_objname = 0; PyObject *__pyx_v_expected_objtype = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_assert_all_types (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_expected_objtype = __Pyx_ArgsSlice_FASTCALL(__pyx_args, 1, __pyx_nargs); if (unlikely(!__pyx_v_expected_objtype)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_v_expected_objtype); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_objname,0}; PyObject* values[2] = {0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_expected_objtype); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_17_assert_all_types_2generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_68_assert_all_types(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_objname, PyObject *__pyx_v_expected_objtype) { PyObject *__pyx_v_n = NULL; PyObject *__pyx_gb_6gofast_5tools_9coreutils_17_assert_all_types_2generator5 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__102) __Pyx_TraceCall("_assert_all_types", __pyx_f[0], 1853, 0, __PYX_ERR(0, 1853, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils._assert_all_types", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_17_assert_all_types_2generator5); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__398 = PyTuple_Pack(6, __pyx_n_s_obj, __pyx_n_s_objname, __pyx_n_s_expected_objtype, __pyx_n_s_n, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__398)) __PYX_ERR(0, 1853, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__398); __Pyx_GIVEREF(__pyx_tuple__398); /* … */ __Pyx_TraceLine(1853,0,__PYX_ERR(0, 1853, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(1853,0,__PYX_ERR(0, 1853, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_obj, __pyx_n_s_object) < 0) __PYX_ERR(0, 1853, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_objname, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 1853, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_expected_objtype, __pyx_n_s_type_2) < 0) __PYX_ERR(0, 1853, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_object) < 0) __PYX_ERR(0, 1853, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_69_assert_all_types, 0, __pyx_n_s_assert_all_types, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__102)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1853, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_assert_all_types, __pyx_t_2) < 0) __PYX_ERR(0, 1853, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__102 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__398, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_assert_all_types, 1853, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__102)) __PYX_ERR(0, 1853, __pyx_L1_error)
1854: obj: object ,
1855: *expected_objtype: type,
+1856: objname:str=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1853, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args == 1) { const Py_ssize_t index = 1; PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1853, __pyx_L3_error) } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; const Py_ssize_t used_pos_args = (kwd_pos_args < 1) ? kwd_pos_args : 1; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, used_pos_args, "_assert_all_types") < 0)) __PYX_ERR(0, 1853, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_obj = values[0]; __pyx_v_objname = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_assert_all_types", 0, 1, 1, __pyx_nargs); __PYX_ERR(0, 1853, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_expected_objtype); __pyx_v_expected_objtype = 0; __Pyx_AddTraceback("gofast.tools.coreutils._assert_all_types", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_objname), (&PyUnicode_Type), 1, "objname", 1))) __PYX_ERR(0, 1856, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_68_assert_all_types(__pyx_self, __pyx_v_obj, __pyx_v_objname, __pyx_v_expected_objtype); /* … */ __Pyx_TraceLine(1856,0,__PYX_ERR(0, 1856, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_objname, Py_None) < 0) __PYX_ERR(0, 1853, __pyx_L1_error)
1857: ) -> object:
1858: """ Quick assertion of object type. Raises a `TypeError` if wrong type
1859: is passed as an argument. For polishing the error message, one can add
1860: the object name `objname` for specifying the object that raises errors
1861: for letting the users to be aware of the reason of failure."""
1862: # if np.issubdtype(a1.dtype, np.integer):
+1863: if not isinstance( obj, expected_objtype):
__Pyx_TraceLine(1863,0,__PYX_ERR(0, 1863, __pyx_L1_error)) __pyx_t_1 = PyObject_IsInstance(__pyx_v_obj, __pyx_v_expected_objtype); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 1863, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (unlikely(__pyx_t_2)) { /* … */ }
+1864: n=str(objname) + ' expects' if objname is not None else 'Expects'
__Pyx_TraceLine(1864,0,__PYX_ERR(0, 1864, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_objname != ((PyObject*)Py_None)); if (__pyx_t_2) { __pyx_t_4 = __Pyx_PyObject_Str(__pyx_v_objname); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_kp_u_expects); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __pyx_t_5; __pyx_t_5 = 0; } else { __Pyx_INCREF(__pyx_n_u_Expects); __pyx_t_3 = __pyx_n_u_Expects; } __pyx_v_n = __pyx_t_3; __pyx_t_3 = 0;
+1865: raise TypeError (
__Pyx_TraceLine(1865,0,__PYX_ERR(0, 1865, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1865, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 1865, __pyx_L1_error)
+1866: f"{n} type{'s' if len(expected_objtype)>1 else ''} "
__Pyx_TraceLine(1866,0,__PYX_ERR(0, 1866, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1866, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = 127; __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_n, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1866, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_type); __pyx_t_6 += 5; __Pyx_GIVEREF(__pyx_kp_u_type); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u_type); __pyx_t_8 = __Pyx_PyTuple_GET_SIZE(__pyx_v_expected_objtype); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1866, __pyx_L1_error) __pyx_t_2 = (__pyx_t_8 > 1); if (__pyx_t_2) { __Pyx_INCREF(__pyx_n_u_s_2); __pyx_t_5 = __pyx_n_u_s_2; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_5 = __pyx_kp_u__22; } __pyx_t_4 = __Pyx_PyUnicode_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1866, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_6 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_u__14); /* … */ __Pyx_TraceLine(1866,0,__PYX_ERR(0, 1866, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_3, 8, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1866, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+1867: f"{smart_format(tuple (o.__name__ for o in expected_objtype))}"
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_17_assert_all_types_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_6_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_6_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_6_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_6_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 1867, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_17_assert_all_types_2generator5, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_assert_all_types_locals_genexpr, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils._assert_all_types.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_17_assert_all_types_2generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1867, __pyx_L1_error)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1867, __pyx_L1_error) }
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
for (;;) {
{
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1867, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 1867, __pyx_L1_error)
#else
__pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_o);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_o, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_o, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
__Pyx_XGIVEREF(__pyx_t_1);
__pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
__pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
/* return from generator, yielding value */
__pyx_generator->resume_label = 1;
return __pyx_r;
__pyx_L6_resume_from_yield:;
__pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
__pyx_cur_scope->__pyx_t_0 = 0;
__Pyx_XGOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1867, __pyx_L1_error)
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(1867,0,__PYX_ERR(0, 1867, __pyx_L1_error))
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_9 = __pyx_pf_6gofast_5tools_9coreutils_17_assert_all_types_genexpr(NULL, __pyx_v_expected_objtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_10 = __Pyx_PySequence_Tuple(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_10);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_9 = NULL;
__pyx_t_11 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_9)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_9);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
__pyx_t_11 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_10};
__pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_11, 1+__pyx_t_11);
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
__pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1867, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_7;
__pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_5);
__pyx_t_5 = 0;
__Pyx_INCREF(__pyx_kp_u_but);
__pyx_t_6 += 5;
__Pyx_GIVEREF(__pyx_kp_u_but);
PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_kp_u_but);
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_6_genexpr {
PyObject_HEAD
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_o;
PyObject *__pyx_t_0;
Py_ssize_t __pyx_t_1;
};
+1868: f" but {type(obj).__name__!r} is given.")
__Pyx_TraceLine(1868,0,__PYX_ERR(0, 1868, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_obj)), __pyx_n_s_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1868, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_5), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1868, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_is_given); __pyx_t_6 += 10; __Pyx_GIVEREF(__pyx_kp_u_is_given); PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_kp_u_is_given);
1869:
+1870: return obj
__Pyx_TraceLine(1870,0,__PYX_ERR(0, 1870, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_obj); __pyx_r = __pyx_v_obj; goto __pyx_L0;
1871:
1872:
+1873: def savepath_ (nameOfPath):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_71savepath_(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_70savepath_, "\n Shortcut to create a folder \n :param nameOfPath: Path name to save file\n :type nameOfPath: str \n \n :return: \n New folder created. If the `nameOfPath` exists, will return ``None``\n :rtype:str \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_71savepath_ = {"savepath_", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_71savepath_, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_70savepath_}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_71savepath_(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_nameOfPath = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("savepath_ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nameOfPath,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_nameOfPath)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1873, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "savepath_") < 0)) __PYX_ERR(0, 1873, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_nameOfPath = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("savepath_", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1873, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.savepath_", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_70savepath_(__pyx_self, __pyx_v_nameOfPath); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_70savepath_(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_nameOfPath) { PyObject *__pyx_v_savepath = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__103) __Pyx_TraceCall("savepath_", __pyx_f[0], 1873, 0, __PYX_ERR(0, 1873, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.savepath_", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_savepath); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__399 = PyTuple_Pack(2, __pyx_n_s_nameOfPath, __pyx_n_s_savepath); if (unlikely(!__pyx_tuple__399)) __PYX_ERR(0, 1873, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__399); __Pyx_GIVEREF(__pyx_tuple__399); /* … */ __Pyx_TraceLine(1873,0,__PYX_ERR(0, 1873, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_71savepath_, 0, __pyx_n_s_savepath_2, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__103)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1873, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_savepath_2, __pyx_t_2) < 0) __PYX_ERR(0, 1873, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__103 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__399, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_savepath_2, 1873, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__103)) __PYX_ERR(0, 1873, __pyx_L1_error)
1874: """
1875: Shortcut to create a folder
1876: :param nameOfPath: Path name to save file
1877: :type nameOfPath: str
1878:
1879: :return:
1880: New folder created. If the `nameOfPath` exists, will return ``None``
1881: :rtype:str
1882:
1883: """
1884:
+1885: try :
__Pyx_TraceLine(1885,0,__PYX_ERR(0, 1885, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L8_try_end:; }
+1886: savepath = os.path.join(os.getcwd(), nameOfPath)
__Pyx_TraceLine(1886,0,__PYX_ERR(0, 1886, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_join); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_t_6, __pyx_v_nameOfPath}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1886, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_savepath = __pyx_t_4; __pyx_t_4 = 0;
+1887: if not os.path.isdir(savepath):
__Pyx_TraceLine(1887,0,__PYX_ERR(0, 1887, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1887, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1887, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isdir); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1887, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_savepath}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1887, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1887, __pyx_L3_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_11 = (!__pyx_t_10); if (__pyx_t_11) { /* … */ }
+1888: os.mkdir(nameOfPath)# mode =0o666)
__Pyx_TraceLine(1888,0,__PYX_ERR(0, 1888, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1888, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_mkdir); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1888, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_nameOfPath}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1888, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+1889: except :
__Pyx_TraceLine(1889,0,__PYX_ERR(0, 1889, __pyx_L5_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.savepath_", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 1889, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+1890: warnings.warn("The path seems to be existed !")
__Pyx_TraceLine(1890,0,__PYX_ERR(0, 1890, __pyx_L5_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_warnings); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1890, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_warn); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1890, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_u_The_path_seems_to_be_existed_2}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1890, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+1891: return
__Pyx_TraceLine(1891,0,__PYX_ERR(0, 1891, __pyx_L5_except_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; }
+1892: return savepath
__Pyx_TraceLine(1892,0,__PYX_ERR(0, 1892, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_savepath); __pyx_r = __pyx_v_savepath; goto __pyx_L0;
1893:
1894:
+1895: def drawn_boundaries(erp_data, appRes, index):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_73drawn_boundaries(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_72drawn_boundaries, "\n Function to drawn anomaly boundary \n and return the anomaly with its boundaries\n \n :param erp_data: erp profile \n :type erp_data: array_like or list \n \n :param appRes: resistivity value of minimum pk anomaly \n :type appRes: float \n \n :param index: index of minimum pk anomaly \n :type index: int \n \n :return: anomaly boundary \n :rtype: list of array_like \n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_73drawn_boundaries = {"drawn_boundaries", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_73drawn_boundaries, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_72drawn_boundaries}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_73drawn_boundaries(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_erp_data = 0; PyObject *__pyx_v_appRes = 0; PyObject *__pyx_v_index = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("drawn_boundaries (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_erp_data,&__pyx_n_s_appRes,&__pyx_n_s_index,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_erp_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1895, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_appRes)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1895, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("drawn_boundaries", 1, 3, 3, 1); __PYX_ERR(0, 1895, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_index)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1895, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("drawn_boundaries", 1, 3, 3, 2); __PYX_ERR(0, 1895, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "drawn_boundaries") < 0)) __PYX_ERR(0, 1895, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_erp_data = values[0]; __pyx_v_appRes = values[1]; __pyx_v_index = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("drawn_boundaries", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 1895, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.drawn_boundaries", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_72drawn_boundaries(__pyx_self, __pyx_v_erp_data, __pyx_v_appRes, __pyx_v_index); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_72drawn_boundaries(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_erp_data, PyObject *__pyx_v_appRes, PyObject *__pyx_v_index) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries *__pyx_cur_scope; long __pyx_v_f; PyObject *__pyx_v_loop_sideBound = 0; PyObject *__pyx_v_left_term = NULL; PyObject *__pyx_v_left_limit = NULL; PyObject *__pyx_v_right_term = NULL; PyObject *__pyx_v_right_limit = NULL; PyObject *__pyx_v_anomalyBounds = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__104) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 1895, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("drawn_boundaries", __pyx_f[0], 1895, 0, __PYX_ERR(0, 1895, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_appRes = __pyx_v_appRes; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_appRes); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_appRes); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.drawn_boundaries", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_loop_sideBound); __Pyx_XDECREF(__pyx_v_left_term); __Pyx_XDECREF(__pyx_v_left_limit); __Pyx_XDECREF(__pyx_v_right_term); __Pyx_XDECREF(__pyx_v_right_limit); __Pyx_XDECREF(__pyx_v_anomalyBounds); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__400 = PyTuple_Pack(11, __pyx_n_s_erp_data, __pyx_n_s_appRes, __pyx_n_s_index, __pyx_n_s_f, __pyx_n_s_loop_sideBound, __pyx_n_s_loop_sideBound, __pyx_n_s_left_term, __pyx_n_s_left_limit, __pyx_n_s_right_term, __pyx_n_s_right_limit, __pyx_n_s_anomalyBounds); if (unlikely(!__pyx_tuple__400)) __PYX_ERR(0, 1895, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__400); __Pyx_GIVEREF(__pyx_tuple__400); /* … */ __Pyx_TraceLine(1895,0,__PYX_ERR(0, 1895, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_73drawn_boundaries, 0, __pyx_n_s_drawn_boundaries, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__104)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1895, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_drawn_boundaries, __pyx_t_2) < 0) __PYX_ERR(0, 1895, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__104 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__400, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_drawn_boundaries, 1895, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__104)) __PYX_ERR(0, 1895, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries { PyObject_HEAD PyObject *__pyx_v_appRes; };
1896: """
1897: Function to drawn anomaly boundary
1898: and return the anomaly with its boundaries
1899:
1900: :param erp_data: erp profile
1901: :type erp_data: array_like or list
1902:
1903: :param appRes: resistivity value of minimum pk anomaly
1904: :type appRes: float
1905:
1906: :param index: index of minimum pk anomaly
1907: :type index: int
1908:
1909: :return: anomaly boundary
1910: :rtype: list of array_like
1911:
1912: """
+1913: f = 0 # flag to mention which part must be calculated
__Pyx_TraceLine(1913,0,__PYX_ERR(0, 1913, __pyx_L1_error)) __pyx_v_f = 0;
+1914: if index ==0 :
__Pyx_TraceLine(1914,0,__PYX_ERR(0, 1914, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_index, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1914, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+1915: f = 1 # compute only right part
__Pyx_TraceLine(1915,0,__PYX_ERR(0, 1915, __pyx_L1_error)) __pyx_v_f = 1;
+1916: elif appRes ==erp_data[-1]:
__Pyx_TraceLine(1916,0,__PYX_ERR(0, 1916, __pyx_L1_error)) __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_erp_data, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_appRes, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1916, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1916, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ } __pyx_L3:;
+1917: f=2 # compute left part
__Pyx_TraceLine(1917,0,__PYX_ERR(0, 1917, __pyx_L1_error)) __pyx_v_f = 2;
1918:
+1919: def loop_sideBound(term):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_16drawn_boundaries_1loop_sideBound(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_16drawn_boundaries_loop_sideBound, "\n loop side bar from anomaly and find the term side \n \n :param term: is array of left or right side of anomaly.\n :type term: array \n \n :return: side bar \n :type: array_like \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_16drawn_boundaries_1loop_sideBound = {"loop_sideBound", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_16drawn_boundaries_1loop_sideBound, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_16drawn_boundaries_loop_sideBound}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_16drawn_boundaries_1loop_sideBound(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_term = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("loop_sideBound (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_term,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_term)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1919, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "loop_sideBound") < 0)) __PYX_ERR(0, 1919, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_term = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("loop_sideBound", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1919, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.drawn_boundaries.loop_sideBound", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_16drawn_boundaries_loop_sideBound(__pyx_self, __pyx_v_term); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_16drawn_boundaries_loop_sideBound(PyObject *__pyx_self, PyObject *__pyx_v_term) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries *__pyx_cur_scope; struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries *__pyx_outer_scope; PyObject *__pyx_v_tem_drawn = NULL; PyObject *__pyx_v_maxT = NULL; CYTHON_UNUSED PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_tem_rho = NULL; PyObject *__pyx_v_diffRes_betw_2pts = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_7_drawn_boundaries *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_TraceCall("loop_sideBound", __pyx_f[0], 1919, 0, __PYX_ERR(0, 1919, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.drawn_boundaries.loop_sideBound", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tem_drawn); __Pyx_XDECREF(__pyx_v_maxT); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_tem_rho); __Pyx_XDECREF(__pyx_v_diffRes_betw_2pts); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__105 = PyTuple_Pack(6, __pyx_n_s_term, __pyx_n_s_tem_drawn, __pyx_n_s_maxT, __pyx_n_s_ii, __pyx_n_s_tem_rho, __pyx_n_s_diffRes_betw_2pts); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(0, 1919, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__105); __Pyx_GIVEREF(__pyx_tuple__105); /* … */ __Pyx_TraceLine(1919,0,__PYX_ERR(0, 1919, __pyx_L1_error)) __pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_16drawn_boundaries_1loop_sideBound, 0, __pyx_n_s_drawn_boundaries_locals_loop_sid, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__106)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_loop_sideBound = __pyx_t_3; __pyx_t_3 = 0; __pyx_codeobj__106 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_loop_sideBound, 1919, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__106)) __PYX_ERR(0, 1919, __pyx_L1_error)
1920: """
1921: loop side bar from anomaly and find the term side
1922:
1923: :param term: is array of left or right side of anomaly.
1924: :type term: array
1925:
1926: :return: side bar
1927: :type: array_like
1928: """
+1929: tem_drawn =[]
__Pyx_TraceLine(1929,0,__PYX_ERR(0, 1929, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1929, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_tem_drawn = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+1930: maxT=0
__Pyx_TraceLine(1930,0,__PYX_ERR(0, 1930, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_v_maxT = __pyx_int_0;
1931:
+1932: for ii, tem_rho in enumerate(term) :
__Pyx_TraceLine(1932,0,__PYX_ERR(0, 1932, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_term)) || PyTuple_CheckExact(__pyx_v_term)) { __pyx_t_2 = __pyx_v_term; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_term); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1932, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1932, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 1932, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1932, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 1932, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 1932, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_tem_rho, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_1); __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(1932,0,__PYX_ERR(0, 1932, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L6_for_end; __pyx_L4_break:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L6_for_end; __pyx_L6_for_end:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1933:
+1934: diffRes_betw_2pts= tem_rho - appRes
__Pyx_TraceLine(1934,0,__PYX_ERR(0, 1934, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_appRes)) { __Pyx_RaiseClosureNameError("appRes"); __PYX_ERR(0, 1934, __pyx_L1_error) } __pyx_t_5 = PyNumber_Subtract(__pyx_v_tem_rho, __pyx_cur_scope->__pyx_v_appRes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1934, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_diffRes_betw_2pts, __pyx_t_5); __pyx_t_5 = 0;
+1935: if diffRes_betw_2pts > maxT :
__Pyx_TraceLine(1935,0,__PYX_ERR(0, 1935, __pyx_L1_error)) __pyx_t_5 = PyObject_RichCompare(__pyx_v_diffRes_betw_2pts, __pyx_v_maxT, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1935, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1935, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { /* … */ goto __pyx_L5; }
+1936: maxT = diffRes_betw_2pts
__Pyx_TraceLine(1936,0,__PYX_ERR(0, 1936, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_diffRes_betw_2pts); __Pyx_DECREF_SET(__pyx_v_maxT, __pyx_v_diffRes_betw_2pts);
+1937: tem_drawn.append(tem_rho)
__Pyx_TraceLine(1937,0,__PYX_ERR(0, 1937, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_tem_drawn, __pyx_v_tem_rho); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 1937, __pyx_L1_error)
+1938: elif diffRes_betw_2pts < maxT :
__Pyx_TraceLine(1938,0,__PYX_ERR(0, 1938, __pyx_L1_error)) __pyx_t_5 = PyObject_RichCompare(__pyx_v_diffRes_betw_2pts, __pyx_v_maxT, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1938, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1938, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { /* … */ } __pyx_L5:;
1939: # rho_limit = tem_rho
+1940: break
__Pyx_TraceLine(1940,0,__PYX_ERR(0, 1940, __pyx_L1_error)) goto __pyx_L4_break;
+1941: return np.array(tem_drawn)
__Pyx_TraceLine(1941,0,__PYX_ERR(0, 1941, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_tem_drawn}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1942: # first broke erp profile from the anomalies
+1943: if f ==0 or f==2 :
__Pyx_TraceLine(1943,0,__PYX_ERR(0, 1943, __pyx_L1_error)) switch (__pyx_v_f) { case 0: CYTHON_FALLTHROUGH; case 2: /* … */ break; default: break; }
+1944: left_term = erp_data[:index][::-1] # flip left term for looping
__Pyx_TraceLine(1944,0,__PYX_ERR(0, 1944, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_erp_data, 0, 0, NULL, &__pyx_v_index, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1944, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_slice__107); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1944, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_left_term = __pyx_t_2; __pyx_t_2 = 0; /* … */ __pyx_slice__107 = PySlice_New(Py_None, Py_None, __pyx_int_neg_1); if (unlikely(!__pyx_slice__107)) __PYX_ERR(0, 1944, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__107); __Pyx_GIVEREF(__pyx_slice__107);
1945: # flip again to keep the order
+1946: left_limit = loop_sideBound(term=left_term)[::-1]
__Pyx_TraceLine(1946,0,__PYX_ERR(0, 1946, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_term, __pyx_v_left_term) < 0) __PYX_ERR(0, 1946, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_loop_sideBound, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_slice__107); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_left_limit = __pyx_t_2; __pyx_t_2 = 0;
1947:
+1948: if f==0 or f ==1 :
__Pyx_TraceLine(1948,0,__PYX_ERR(0, 1948, __pyx_L1_error)) switch (__pyx_v_f) { case 0: CYTHON_FALLTHROUGH; case 1: /* … */ break; default: break; }
+1949: right_term= erp_data[index :]
__Pyx_TraceLine(1949,0,__PYX_ERR(0, 1949, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_erp_data, 0, 0, &__pyx_v_index, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1949, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_right_term = __pyx_t_2; __pyx_t_2 = 0;
+1950: right_limit=loop_sideBound(right_term)
__Pyx_TraceLine(1950,0,__PYX_ERR(0, 1950, __pyx_L1_error)) __pyx_t_2 = __pyx_pf_6gofast_5tools_9coreutils_16drawn_boundaries_loop_sideBound(__pyx_v_loop_sideBound, __pyx_v_right_term); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_right_limit = __pyx_t_2; __pyx_t_2 = 0;
1951: # concat right and left to get the complete anomaly
+1952: if f==2:
__Pyx_TraceLine(1952,0,__PYX_ERR(0, 1952, __pyx_L1_error)) switch (__pyx_v_f) { case 2: /* … */ break; case 1:
+1953: anomalyBounds = np.append(left_limit,appRes)
__Pyx_TraceLine(1953,0,__PYX_ERR(0, 1953, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_append); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_v_left_limit)) { __Pyx_RaiseUnboundLocalError("left_limit"); __PYX_ERR(0, 1953, __pyx_L1_error) } __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_left_limit, __pyx_cur_scope->__pyx_v_appRes}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_anomalyBounds = __pyx_t_2; __pyx_t_2 = 0;
1954:
+1955: elif f ==1 :
break;
default:
+1956: anomalyBounds = np.array([appRes]+ right_limit.tolist())
__Pyx_TraceLine(1956,0,__PYX_ERR(0, 1956, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_appRes); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_appRes); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_cur_scope->__pyx_v_appRes)) __PYX_ERR(0, 1956, __pyx_L1_error); if (unlikely(!__pyx_v_right_limit)) { __Pyx_RaiseUnboundLocalError("right_limit"); __PYX_ERR(0, 1956, __pyx_L1_error) } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_right_limit, __pyx_n_s_tolist); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_7}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_anomalyBounds = __pyx_t_2; __pyx_t_2 = 0;
1957: else:
+1958: left_limit = np.append(left_limit, appRes)
__Pyx_TraceLine(1958,0,__PYX_ERR(0, 1958, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_append); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_v_left_limit)) { __Pyx_RaiseUnboundLocalError("left_limit"); __PYX_ERR(0, 1958, __pyx_L1_error) } __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_left_limit, __pyx_cur_scope->__pyx_v_appRes}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_left_limit, __pyx_t_2); __pyx_t_2 = 0;
+1959: anomalyBounds = np.concatenate((left_limit, right_limit))
__Pyx_TraceLine(1959,0,__PYX_ERR(0, 1959, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_v_right_limit)) { __Pyx_RaiseUnboundLocalError("right_limit"); __PYX_ERR(0, 1959, __pyx_L1_error) } __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_left_limit); __Pyx_GIVEREF(__pyx_v_left_limit); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_left_limit)) __PYX_ERR(0, 1959, __pyx_L1_error); __Pyx_INCREF(__pyx_v_right_limit); __Pyx_GIVEREF(__pyx_v_right_limit); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_right_limit)) __PYX_ERR(0, 1959, __pyx_L1_error); __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_7}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_anomalyBounds = __pyx_t_2; __pyx_t_2 = 0; break; }
1960:
+1961: return appRes, index, anomalyBounds
__Pyx_TraceLine(1961,0,__PYX_ERR(0, 1961, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_appRes); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_appRes); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_appRes)) __PYX_ERR(0, 1961, __pyx_L1_error); __Pyx_INCREF(__pyx_v_index); __Pyx_GIVEREF(__pyx_v_index); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_index)) __PYX_ERR(0, 1961, __pyx_L1_error); __Pyx_INCREF(__pyx_v_anomalyBounds); __Pyx_GIVEREF(__pyx_v_anomalyBounds); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_anomalyBounds)) __PYX_ERR(0, 1961, __pyx_L1_error); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
1962:
+1963: def serialize_data(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_312__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 1963, 0, __PYX_ERR(0, 1963, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(1967,0,__PYX_ERR(0, 1967, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1963, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None)) __PYX_ERR(0, 1963, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_True));
__Pyx_GIVEREF(((PyObject *)Py_True));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_True))) __PYX_ERR(0, 1963, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, Py_None)) __PYX_ERR(0, 1963, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_verbose);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_verbose);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self)->__pyx_arg_verbose)) __PYX_ERR(0, 1963, __pyx_L1_error);
/* … */
__Pyx_TraceLine(1963,0,__PYX_ERR(0, 1963, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1963, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 1963, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 1963, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_75serialize_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_74serialize_data, " Store a data into a binary file \n \n :param data: Object\n Object to store into a binary file. \n :param filename: str\n Name of file to serialize. If 'None', should create automatically. \n :param savepath: str, PathLike object\n Directory to save file. If not exists should automaticallycreate.\n :param force: bool\n If ``True``, remove the old file if it exists, otherwise will \n create a new incremenmted file.\n :param verbose: int, get more message.\n :return: dumped or serialized filename.\n \n :Example:\n \n >>> import numpy as np\n >>> import gofast.tools.coreutils import serialize_data\n >>> data = np.arange(15)\n >>> file = serialize_data(data, filename=None, force=True, \n ... savepath =None, verbose =3)\n >>> file\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_75serialize_data = {"serialize_data", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_75serialize_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_74serialize_data};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_75serialize_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_data = 0;
PyObject *__pyx_v_filename = 0;
PyObject *__pyx_v_force = 0;
PyObject *__pyx_v_savepath = 0;
PyObject *__pyx_v_verbose = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("serialize_data (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_filename,&__pyx_n_s_force,&__pyx_n_s_savepath,&__pyx_n_s_verbose,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults3 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_self);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_74serialize_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_filename, PyObject *__pyx_v_force, PyObject *__pyx_v_savepath, PyObject *__pyx_v_verbose) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data *__pyx_cur_scope;
PyObject *__pyx_v__cif = 0;
PyObject *__pyx_v_file_exist = NULL;
PyObject *__pyx_v_wfile = NULL;
PyObject *__pyx_v_dirname = NULL;
PyObject *__pyx_v_file = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__109)
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 1963, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__Pyx_TraceCall("serialize_data", __pyx_f[0], 1963, 0, __PYX_ERR(0, 1963, __pyx_L1_error));
__pyx_cur_scope->__pyx_v_verbose = __pyx_v_verbose;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_verbose);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_verbose);
__Pyx_INCREF(__pyx_v_filename);
__Pyx_INCREF(__pyx_v_savepath);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_XDECREF(__pyx_t_12);
__Pyx_XDECREF(__pyx_t_21);
__Pyx_AddTraceback("gofast.tools.coreutils.serialize_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v__cif);
__Pyx_XDECREF(__pyx_v_file_exist);
__Pyx_XDECREF(__pyx_v_wfile);
__Pyx_XDECREF(__pyx_v_dirname);
__Pyx_XDECREF(__pyx_v_file);
__Pyx_XDECREF(__pyx_v_filename);
__Pyx_XDECREF(__pyx_v_savepath);
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__401 = PyTuple_Pack(11, __pyx_n_s_data, __pyx_n_s_filename, __pyx_n_s_force, __pyx_n_s_savepath, __pyx_n_s_verbose, __pyx_n_s_cif, __pyx_n_s_cif, __pyx_n_s_file_exist, __pyx_n_s_wfile, __pyx_n_s_dirname, __pyx_n_s_file); if (unlikely(!__pyx_tuple__401)) __PYX_ERR(0, 1963, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__401);
__Pyx_GIVEREF(__pyx_tuple__401);
/* … */
__Pyx_TraceLine(1963,0,__PYX_ERR(0, 1963, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1963, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_verbose, __pyx_n_s_int) < 0) __PYX_ERR(0, 1963, __pyx_L1_error)
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_75serialize_data, 0, __pyx_n_s_serialize_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__109)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1963, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults3), 1)) __PYX_ERR(0, 1963, __pyx_L1_error)
__pyx_codeobj__109 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__401, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_serialize_data, 1963, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__109)) __PYX_ERR(0, 1963, __pyx_L1_error)
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data {
PyObject_HEAD
PyObject *__pyx_v_verbose;
};
1964: data,
+1965: filename=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
1966: force=True,
+1967: savepath=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_verbose); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1963, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1963, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_force); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1963, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1963, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1963, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "serialize_data") < 0)) __PYX_ERR(0, 1963, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_filename = values[1]; __pyx_v_force = values[2]; __pyx_v_savepath = values[3]; __pyx_v_verbose = ((PyObject*)values[4]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("serialize_data", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 1963, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_verbose), (&PyInt_Type), 0, "verbose", 1))) __PYX_ERR(0, 1968, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_74serialize_data(__pyx_self, __pyx_v_data, __pyx_v_filename, __pyx_v_force, __pyx_v_savepath, __pyx_v_verbose);
+1968: verbose:int =0
__Pyx_TraceLine(1968,0,__PYX_ERR(0, 1968, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_0)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_0))) __PYX_ERR(0, 1968, __pyx_L1_error) __Pyx_INCREF(__pyx_int_0); __Pyx_CyFunction_Defaults(__pyx_defaults3, __pyx_t_4)->__pyx_arg_verbose = ((PyObject*)__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_6gofast_5tools_9coreutils_312__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_serialize_data, __pyx_t_4) < 0) __PYX_ERR(0, 1963, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1969: ):
1970: """ Store a data into a binary file
1971:
1972: :param data: Object
1973: Object to store into a binary file.
1974: :param filename: str
1975: Name of file to serialize. If 'None', should create automatically.
1976: :param savepath: str, PathLike object
1977: Directory to save file. If not exists should automaticallycreate.
1978: :param force: bool
1979: If ``True``, remove the old file if it exists, otherwise will
1980: create a new incremenmted file.
1981: :param verbose: int, get more message.
1982: :return: dumped or serialized filename.
1983:
1984: :Example:
1985:
1986: >>> import numpy as np
1987: >>> import gofast.tools.coreutils import serialize_data
1988: >>> data = np.arange(15)
1989: >>> file = serialize_data(data, filename=None, force=True,
1990: ... savepath =None, verbose =3)
1991: >>> file
1992: """
1993:
+1994: def _cif(filename, force):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_14serialize_data_1_cif(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_14serialize_data__cif, " Control the file. If `force` is ``True`` then remove the old file, \n Otherwise create a new file with datetime infos."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_14serialize_data_1_cif = {"_cif", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_14serialize_data_1_cif, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_14serialize_data__cif}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_14serialize_data_1_cif(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename = 0; PyObject *__pyx_v_force = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_cif (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename,&__pyx_n_s_force,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1994, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_force)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1994, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_cif", 1, 2, 2, 1); __PYX_ERR(0, 1994, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_cif") < 0)) __PYX_ERR(0, 1994, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_filename = values[0]; __pyx_v_force = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_cif", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1994, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data._cif", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_14serialize_data__cif(__pyx_self, __pyx_v_filename, __pyx_v_force); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_14serialize_data__cif(PyObject *__pyx_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_force) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data *__pyx_cur_scope; struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data *__pyx_outer_scope; PyObject *__pyx_v_f = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_8_serialize_data *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_TraceCall("_cif", __pyx_f[0], 1994, 0, __PYX_ERR(0, 1994, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data._cif", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_f); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__110 = PyTuple_Pack(3, __pyx_n_s_filename, __pyx_n_s_force, __pyx_n_s_f); if (unlikely(!__pyx_tuple__110)) __PYX_ERR(0, 1994, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__110); __Pyx_GIVEREF(__pyx_tuple__110); /* … */ __Pyx_TraceLine(1994,0,__PYX_ERR(0, 1994, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_14serialize_data_1_cif, 0, __pyx_n_s_serialize_data_locals__cif, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__111)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1994, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__cif = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__111 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__110, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_cif, 1994, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__111)) __PYX_ERR(0, 1994, __pyx_L1_error)
1995: """ Control the file. If `force` is ``True`` then remove the old file,
1996: Otherwise create a new file with datetime infos."""
+1997: f = copy.deepcopy(filename)
__Pyx_TraceLine(1997,0,__PYX_ERR(0, 1997, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_filename}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1997, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_f = __pyx_t_1; __pyx_t_1 = 0;
+1998: if force :
__Pyx_TraceLine(1998,0,__PYX_ERR(0, 1998, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1998, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+1999: os.remove(filename)
__Pyx_TraceLine(1999,0,__PYX_ERR(0, 1999, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_remove); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_filename}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2000: if verbose >2: print(f" File {os.path.basename(filename)!r} "
__Pyx_TraceLine(2000,0,__PYX_ERR(0, 2000, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_verbose)) { __Pyx_RaiseClosureNameError("verbose"); __PYX_ERR(0, 2000, __pyx_L1_error) } __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_verbose, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2000, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_File); __pyx_t_6 += 6; __Pyx_GIVEREF(__pyx_kp_u_File); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_File); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_filename}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_has_been_removed); __pyx_t_6 += 19; __Pyx_GIVEREF(__pyx_kp_u_has_been_removed); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_has_been_removed); __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; }
2001: "has been removed. ")
+2002: return None
__Pyx_TraceLine(2002,0,__PYX_ERR(0, 2002, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
2003: else :
2004: # that change the name in the realpath
+2005: f= os.path.basename(f).replace('.pkl','') + \
__Pyx_TraceLine(2005,0,__PYX_ERR(0, 2005, __pyx_L1_error)) /*else*/ { /* … */ __Pyx_TraceLine(2006,0,__PYX_ERR(0, 2006, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __Pyx_TraceLine(2005,0,__PYX_ERR(0, 2005, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_f}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__108, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(2005,0,__PYX_ERR(0, 2005, __pyx_L1_error)) __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__108 = PyTuple_Pack(2, __pyx_kp_u_pkl, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__108)) __PYX_ERR(0, 2005, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__108); __Pyx_GIVEREF(__pyx_tuple__108);
+2006: f'{datetime.datetime.now()}'.replace(':', '_')+'.pkl'
__Pyx_TraceLine(2006,0,__PYX_ERR(0, 2006, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_now); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyUnicode_Replace(((PyObject*)__pyx_t_2), __pyx_kp_u__32, __pyx_n_u__8, -1L); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(2006,0,__PYX_ERR(0, 2006, __pyx_L1_error)) __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_kp_u_pkl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_f, __pyx_t_3); __pyx_t_3 = 0;
+2007: return f
__Pyx_TraceLine(2007,0,__PYX_ERR(0, 2007, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_f); __pyx_r = __pyx_v_f; goto __pyx_L0; }
2008:
+2009: if filename is not None:
__Pyx_TraceLine(2009,0,__PYX_ERR(0, 2009, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_filename != Py_None); if (__pyx_t_2) { /* … */ }
+2010: file_exist = os.path.isfile(filename)
__Pyx_TraceLine(2010,0,__PYX_ERR(0, 2010, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isfile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_filename}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_file_exist = __pyx_t_1; __pyx_t_1 = 0;
+2011: if file_exist:
__Pyx_TraceLine(2011,0,__PYX_ERR(0, 2011, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_file_exist); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2011, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+2012: filename = _cif (filename, force)
__Pyx_TraceLine(2012,0,__PYX_ERR(0, 2012, __pyx_L1_error)) __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_14serialize_data__cif(__pyx_v__cif, __pyx_v_filename, __pyx_v_force); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_1); __pyx_t_1 = 0;
+2013: if filename is None:
__Pyx_TraceLine(2013,0,__PYX_ERR(0, 2013, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_filename == Py_None); if (__pyx_t_2) { /* … */ }
+2014: filename ='__mymemoryfile.{}__'.format(datetime.datetime.now())
__Pyx_TraceLine(2014,0,__PYX_ERR(0, 2014, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_mymemoryfile, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_now); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2014, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_1); __pyx_t_1 = 0;
+2015: filename =filename.replace(' ', '_').replace(':', '-')
__Pyx_TraceLine(2015,0,__PYX_ERR(0, 2015, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_replace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__112, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_replace); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__112 = PyTuple_Pack(2, __pyx_kp_u__14, __pyx_n_u__8); if (unlikely(!__pyx_tuple__112)) __PYX_ERR(0, 2015, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__112); __Pyx_GIVEREF(__pyx_tuple__112); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_3); __pyx_t_3 = 0; __pyx_tuple__113 = PyTuple_Pack(2, __pyx_kp_u__32, __pyx_kp_u__29); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 2015, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__113); __Pyx_GIVEREF(__pyx_tuple__113);
+2016: if not isinstance(filename, str):
__Pyx_TraceLine(2016,0,__PYX_ERR(0, 2016, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Check(__pyx_v_filename); __pyx_t_8 = (!__pyx_t_2); if (unlikely(__pyx_t_8)) { /* … */ }
+2017: raise TypeError(f"Filename needs to be a string not {type(filename)}")
__Pyx_TraceLine(2017,0,__PYX_ERR(0, 2017, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_FormatSimple(((PyObject *)Py_TYPE(__pyx_v_filename)), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2017, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Filename_needs_to_be_a_string_no, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2017, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2017, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 2017, __pyx_L1_error)
+2018: if filename.endswith('.pkl'):
__Pyx_TraceLine(2018,0,__PYX_ERR(0, 2018, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_endswith); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2018, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_kp_u_pkl}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2018, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2018, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_8) { /* … */ }
+2019: filename = filename.replace('.pkl', '')
__Pyx_TraceLine(2019,0,__PYX_ERR(0, 2019, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2019, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__108, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2019, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_1); __pyx_t_1 = 0;
2020:
+2021: _logger.info (
__Pyx_TraceLine(2021,0,__PYX_ERR(0, 2021, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2021, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2021, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2022: f"Save data to {'memory' if filename.find('memo')>=0 else filename}.")
__Pyx_TraceLine(2022,0,__PYX_ERR(0, 2022, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_Save_data_to); __pyx_t_9 += 13; __Pyx_GIVEREF(__pyx_kp_u_Save_data_to); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Save_data_to); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_filename, __pyx_n_s_find); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_n_u_memo}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = PyObject_RichCompare(__pyx_t_7, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_8) { __Pyx_INCREF(__pyx_n_u_memory); __pyx_t_6 = __pyx_n_u_memory; } else { __Pyx_INCREF(__pyx_v_filename); __pyx_t_6 = __pyx_v_filename; } __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_6, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_10; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_9 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__26); __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_11}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2021, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2023: try :
__Pyx_TraceLine(2023,0,__PYX_ERR(0, 2023, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L13_try_end; __pyx_L8_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L10_except_error:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L9_exception_handled:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_L13_try_end:; }
+2024: joblib.dump(data, f'{filename}.pkl')
__Pyx_TraceLine(2024,0,__PYX_ERR(0, 2024, __pyx_L8_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_joblib); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2024, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_dump); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2024, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_filename, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2024, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_4, __pyx_kp_u_pkl); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2024, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_data, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2024, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2025: filename +='.pkl'
__Pyx_TraceLine(2025,0,__PYX_ERR(0, 2025, __pyx_L8_error)) __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_filename, __pyx_kp_u_pkl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2025, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_1); __pyx_t_1 = 0;
+2026: if verbose > 2:
__Pyx_TraceLine(2026,0,__PYX_ERR(0, 2026, __pyx_L8_error)) __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_verbose, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2026, __pyx_L8_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2026, __pyx_L8_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_8) { /* … */ }
+2027: print(f'Data dumped in `{filename} using to `~.externals.joblib`!')
__Pyx_TraceLine(2027,0,__PYX_ERR(0, 2027, __pyx_L8_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2027, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_Data_dumped_in); __pyx_t_9 += 16; __Pyx_GIVEREF(__pyx_kp_u_Data_dumped_in); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Data_dumped_in); __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_v_filename, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2027, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_10; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u_using_to_externals_joblib); __pyx_t_9 += 31; __Pyx_GIVEREF(__pyx_kp_u_using_to_externals_joblib); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_using_to_externals_joblib); __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2027, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2027, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2028: except :
__Pyx_TraceLine(2028,0,__PYX_ERR(0, 2028, __pyx_L10_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_11, &__pyx_t_3) < 0) __PYX_ERR(0, 2028, __pyx_L10_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_3);
2029: # Now try to pickle data Serializing data
+2030: with open(filename, 'wb') as wfile:
__Pyx_TraceLine(2030,0,__PYX_ERR(0, 2030, __pyx_L10_except_error)) /*with:*/ { __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2030, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_filename); __Pyx_GIVEREF(__pyx_v_filename); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename)) __PYX_ERR(0, 2030, __pyx_L10_except_error); __Pyx_INCREF(__pyx_n_u_wb); __Pyx_GIVEREF(__pyx_n_u_wb); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_n_u_wb)) __PYX_ERR(0, 2030, __pyx_L10_except_error); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2030, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_16 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_n_s_exit); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2030, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_n_s_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2030, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2030, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __pyx_t_4; __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /*try:*/ { { /*try:*/ { __pyx_v_wfile = __pyx_t_7; __pyx_t_7 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L30_try_end; __pyx_L23_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 2030, __pyx_L25_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6); __pyx_t_12 = PyTuple_Pack(3, __pyx_t_7, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2030, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_12, NULL); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2030, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_20); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; if (__pyx_t_8 < 0) __PYX_ERR(0, 2030, __pyx_L25_except_error) __pyx_t_2 = (!__pyx_t_8); if (unlikely(__pyx_t_2)) { __Pyx_GIVEREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ErrRestoreWithState(__pyx_t_7, __pyx_t_4, __pyx_t_6); __pyx_t_7 = 0; __pyx_t_4 = 0; __pyx_t_6 = 0; __PYX_ERR(0, 2030, __pyx_L25_except_error) } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L24_exception_handled; } __pyx_L25_except_error:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); goto __pyx_L10_except_error; __pyx_L24_exception_handled:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_L30_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_16) { __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 2030, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } goto __pyx_L22; } __pyx_L22:; } goto __pyx_L34; __pyx_L17_error:; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L10_except_error; __pyx_L34:; }
+2031: pickle.dump( data, wfile)
__Pyx_TraceLine(2031,0,__PYX_ERR(0, 2031, __pyx_L23_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pickle); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2031, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dump); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2031, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_data, __pyx_v_wfile}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2031, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+2032: if verbose >2:
__Pyx_TraceLine(2032,0,__PYX_ERR(0, 2032, __pyx_L10_except_error)) __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_verbose, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2032, __pyx_L10_except_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2032, __pyx_L10_except_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_2) { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L9_exception_handled; }
+2033: print( 'Data are well serialized using Python pickle module.`')
__Pyx_TraceLine(2033,0,__PYX_ERR(0, 2033, __pyx_L10_except_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__114, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2033, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple__114 = PyTuple_Pack(1, __pyx_kp_u_Data_are_well_serialized_using_P); if (unlikely(!__pyx_tuple__114)) __PYX_ERR(0, 2033, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__114); __Pyx_GIVEREF(__pyx_tuple__114);
2034: # take the real path of the filename
+2035: filename = os.path.realpath(filename)
__Pyx_TraceLine(2035,0,__PYX_ERR(0, 2035, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_os); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_realpath); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_filename}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2035, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_3); __pyx_t_3 = 0;
2036:
+2037: if savepath is None:
__Pyx_TraceLine(2037,0,__PYX_ERR(0, 2037, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_savepath == Py_None); if (__pyx_t_2) { /* … */ }
+2038: dirname ='_memory_'
__Pyx_TraceLine(2038,0,__PYX_ERR(0, 2038, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_memory_2); __pyx_v_dirname = __pyx_n_u_memory_2;
+2039: try : savepath = sPath(dirname)
__Pyx_TraceLine(2039,0,__PYX_ERR(0, 2039, __pyx_L1_error)) { /*try:*/ { __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_sPath); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2039, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_dirname}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2039, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF_SET(__pyx_v_savepath, __pyx_t_3); __pyx_t_3 = 0; } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L42_try_end; __pyx_L37_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L39_except_error:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_14, __pyx_t_13); goto __pyx_L1_error; __pyx_L38_exception_handled:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_14, __pyx_t_13); __pyx_L42_try_end:; }
+2040: except :
__Pyx_TraceLine(2040,0,__PYX_ERR(0, 2040, __pyx_L39_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_11, &__pyx_t_1) < 0) __PYX_ERR(0, 2040, __pyx_L39_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_1);
2041: # for consistency
+2042: savepath = os.getcwd()
__Pyx_TraceLine(2042,0,__PYX_ERR(0, 2042, __pyx_L39_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2042, __pyx_L39_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2042, __pyx_L39_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2042, __pyx_L39_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF_SET(__pyx_v_savepath, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L38_exception_handled; }
+2043: if savepath is not None:
__Pyx_TraceLine(2043,0,__PYX_ERR(0, 2043, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_savepath != Py_None); if (__pyx_t_2) { /* … */ }
+2044: try:
__Pyx_TraceLine(2044,0,__PYX_ERR(0, 2044, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L51_try_end; __pyx_L46_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L48_except_error:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L47_exception_handled:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_L51_try_end:; }
+2045: shutil.move(filename, savepath)
__Pyx_TraceLine(2045,0,__PYX_ERR(0, 2045, __pyx_L46_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_shutil); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2045, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_move); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2045, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_v_filename, __pyx_v_savepath}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2045, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2046: except :
__Pyx_TraceLine(2046,0,__PYX_ERR(0, 2046, __pyx_L48_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.serialize_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_11) < 0) __PYX_ERR(0, 2046, __pyx_L48_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_11);
+2047: file = _cif (os.path.join(savepath,
__Pyx_TraceLine(2047,0,__PYX_ERR(0, 2047, __pyx_L48_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2047, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2047, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_join); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2047, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(2047,0,__PYX_ERR(0, 2047, __pyx_L48_except_error)) __pyx_t_7 = __pyx_pf_6gofast_5tools_9coreutils_14serialize_data__cif(__pyx_v__cif, __pyx_t_6, __pyx_v_force); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2047, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_file = __pyx_t_7; __pyx_t_7 = 0;
+2048: os.path.basename(filename)), force)
__Pyx_TraceLine(2048,0,__PYX_ERR(0, 2048, __pyx_L48_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_os); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2048, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_path); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2048, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_basename); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2048, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_21)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_21); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_v_filename}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2048, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_v_savepath, __pyx_t_4}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2047, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; }
+2049: if not force:
__Pyx_TraceLine(2049,0,__PYX_ERR(0, 2049, __pyx_L48_except_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2049, __pyx_L48_except_error) __pyx_t_8 = (!__pyx_t_2); if (__pyx_t_8) { /* … */ }
+2050: os.rename(filename, os.path.join(savepath, file) )
__Pyx_TraceLine(2050,0,__PYX_ERR(0, 2050, __pyx_L48_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_rename); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_os); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_path); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_join); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __pyx_t_21 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_21)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_21); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_v_savepath, __pyx_v_file}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_v_filename, __pyx_t_6}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2050, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+2051: if file is None:
__Pyx_TraceLine(2051,0,__PYX_ERR(0, 2051, __pyx_L48_except_error)) __pyx_t_8 = (__pyx_v_file == Py_None); if (__pyx_t_8) { /* … */ }
2052: #take the file in current word
+2053: file = os.path.join(os.getcwd(), filename)
__Pyx_TraceLine(2053,0,__PYX_ERR(0, 2053, __pyx_L48_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_join); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_os); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_21))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_21); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_21, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_21, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __pyx_t_21 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_21)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_21); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_t_6, __pyx_v_filename}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2053, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_file, __pyx_t_7); __pyx_t_7 = 0;
+2054: shutil.move(filename, savepath)
__Pyx_TraceLine(2054,0,__PYX_ERR(0, 2054, __pyx_L48_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_shutil); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2054, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_move); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2054, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_filename, __pyx_v_savepath}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2054, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+2055: filename = os.path.join(savepath, file)
__Pyx_TraceLine(2055,0,__PYX_ERR(0, 2055, __pyx_L48_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2055, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2055, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_join); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2055, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_savepath, __pyx_v_file}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2055, __pyx_L48_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF_SET(__pyx_v_filename, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L47_exception_handled; }
2056:
+2057: if verbose > 0:
__Pyx_TraceLine(2057,0,__PYX_ERR(0, 2057, __pyx_L1_error)) __pyx_t_11 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2057, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2057, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_8) { /* … */ }
+2058: print(f"Data are well stored in {savepath!r} directory.")
__Pyx_TraceLine(2058,0,__PYX_ERR(0, 2058, __pyx_L1_error)) __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_Data_are_well_stored_in); __pyx_t_9 += 24; __Pyx_GIVEREF(__pyx_kp_u_Data_are_well_stored_in); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Data_are_well_stored_in); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_savepath), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_10; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_directory); __pyx_t_9 += 11; __Pyx_GIVEREF(__pyx_kp_u_directory); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_directory); __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_11, 3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
2059:
+2060: return os.path.join(savepath, filename)
__Pyx_TraceLine(2060,0,__PYX_ERR(0, 2060, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_join); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_v_savepath, __pyx_v_filename}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_11; __pyx_t_11 = 0; goto __pyx_L0;
2061:
+2062: def load_serialized_data (filename, verbose=0):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_77load_serialized_data(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_76load_serialized_data, "\n Load data from dumped file.\n \n :param filename: str or path-like object \n Name of dumped data file.\n :return: Data reloaded from dumped file.\n\n :Example:\n \n >>> from gofast.tools.functils import load_serialized_data\n >>> data = load_serialized_data(\n ... filename = '_memory_/__mymemoryfile.2021-10-29_14-49-35.647295__.pkl', \n ... verbose =3)\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_77load_serialized_data = {"load_serialized_data", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_77load_serialized_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_76load_serialized_data}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_77load_serialized_data(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_filename = 0; PyObject *__pyx_v_verbose = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("load_serialized_data (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_filename,&__pyx_n_s_verbose,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_filename)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2062, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2062, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "load_serialized_data") < 0)) __PYX_ERR(0, 2062, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_filename = values[0]; __pyx_v_verbose = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("load_serialized_data", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 2062, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.load_serialized_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_76load_serialized_data(__pyx_self, __pyx_v_filename, __pyx_v_verbose); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_76load_serialized_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_filename, PyObject *__pyx_v_verbose) { PyObject *__pyx_v__filename = NULL; PyObject *__pyx_v_data = NULL; PyObject *__pyx_v_tod = NULL; PyObject *__pyx_v_is_none = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__115) __Pyx_TraceCall("load_serialized_data", __pyx_f[0], 2062, 0, __PYX_ERR(0, 2062, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.load_serialized_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__filename); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_tod); __Pyx_XDECREF(__pyx_v_is_none); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__402 = PyTuple_Pack(6, __pyx_n_s_filename, __pyx_n_s_verbose, __pyx_n_s_filename_2, __pyx_n_s_data, __pyx_n_s_tod, __pyx_n_s_is_none); if (unlikely(!__pyx_tuple__402)) __PYX_ERR(0, 2062, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__402); __Pyx_GIVEREF(__pyx_tuple__402); /* … */ __Pyx_TraceLine(2062,0,__PYX_ERR(0, 2062, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_77load_serialized_data, 0, __pyx_n_s_load_serialized_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__115)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__352); if (PyDict_SetItem(__pyx_d, __pyx_n_s_load_serialized_data, __pyx_t_4) < 0) __PYX_ERR(0, 2062, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__115 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__402, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_load_serialized_data, 2062, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__115)) __PYX_ERR(0, 2062, __pyx_L1_error)
2063: """
2064: Load data from dumped file.
2065:
2066: :param filename: str or path-like object
2067: Name of dumped data file.
2068: :return: Data reloaded from dumped file.
2069:
2070: :Example:
2071:
2072: >>> from gofast.tools.functils import load_serialized_data
2073: >>> data = load_serialized_data(
2074: ... filename = '_memory_/__mymemoryfile.2021-10-29_14-49-35.647295__.pkl',
2075: ... verbose =3)
2076:
2077: """
+2078: if not isinstance(filename, str):
__Pyx_TraceLine(2078,0,__PYX_ERR(0, 2078, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_filename); __pyx_t_2 = (!__pyx_t_1); if (unlikely(__pyx_t_2)) { /* … */ }
+2079: raise TypeError(f'filename should be a <str> not <{type(filename)}>')
__Pyx_TraceLine(2079,0,__PYX_ERR(0, 2079, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_filename_should_be_a_str_not); __pyx_t_4 += 32; __Pyx_GIVEREF(__pyx_kp_u_filename_should_be_a_str_not); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_filename_should_be_a_str_not); __pyx_t_6 = __Pyx_PyObject_FormatSimple(((PyObject *)Py_TYPE(__pyx_v_filename)), __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u__45); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__45); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__45); __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 2079, __pyx_L1_error)
2080:
+2081: if not os.path.isfile(filename):
__Pyx_TraceLine(2081,0,__PYX_ERR(0, 2081, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isfile); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_filename}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2081, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = (!__pyx_t_2); if (unlikely(__pyx_t_1)) { /* … */ }
+2082: raise FileExistsError(f"File {filename!r} does not exist.")
__Pyx_TraceLine(2082,0,__PYX_ERR(0, 2082, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_FileExistsError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2082, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_File_2); __pyx_t_4 += 5; __Pyx_GIVEREF(__pyx_kp_u_File_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_File_2); __pyx_t_7 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_filename), __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2082, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_does_not_exist); __pyx_t_4 += 16; __Pyx_GIVEREF(__pyx_kp_u_does_not_exist); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_does_not_exist); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2082, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 2082, __pyx_L1_error)
2083:
+2084: _filename = os.path.basename(filename)
__Pyx_TraceLine(2084,0,__PYX_ERR(0, 2084, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_basename); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_filename}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_v__filename = __pyx_t_6; __pyx_t_6 = 0;
+2085: _logger.info(
__Pyx_TraceLine(2085,0,__PYX_ERR(0, 2085, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+2086: f"Loading data from {'memory' if _filename.find('memo')>=0 else _filename}.")
__Pyx_TraceLine(2086,0,__PYX_ERR(0, 2086, __pyx_L1_error)) __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Loading_data_from); __pyx_t_4 += 18; __Pyx_GIVEREF(__pyx_kp_u_Loading_data_from); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Loading_data_from); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v__filename, __pyx_n_s_find); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_n_u_memo}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = PyObject_RichCompare(__pyx_t_10, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_1) { __Pyx_INCREF(__pyx_n_u_memory); __pyx_t_9 = __pyx_n_u_memory; } else { __Pyx_INCREF(__pyx_v__filename); __pyx_t_9 = __pyx_v__filename; } __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_9, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u__26); __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_11}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2085, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2087:
+2088: data =None
__Pyx_TraceLine(2088,0,__PYX_ERR(0, 2088, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_data = Py_None;
+2089: try :
__Pyx_TraceLine(2089,0,__PYX_ERR(0, 2089, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_L10_try_end:; }
+2090: data= joblib.load(filename)
__Pyx_TraceLine(2090,0,__PYX_ERR(0, 2090, __pyx_L5_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_joblib); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2090, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_load); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2090, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_filename}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2090, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_6); __pyx_t_6 = 0;
+2091: if verbose >2:
__Pyx_TraceLine(2091,0,__PYX_ERR(0, 2091, __pyx_L5_error)) __pyx_t_6 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2091, __pyx_L5_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 2091, __pyx_L5_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_1) { /* … */ }
+2092: (f"Data from {_filename !r} are sucessfully"
__Pyx_TraceLine(2092,0,__PYX_ERR(0, 2092, __pyx_L5_error)) __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2092, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Data_from); __pyx_t_4 += 10; __Pyx_GIVEREF(__pyx_kp_u_Data_from); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_Data_from); __pyx_t_11 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v__filename), __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2092, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u_are_sucessfully_reloaded_using); __pyx_t_4 += 52; __Pyx_GIVEREF(__pyx_kp_u_are_sucessfully_reloaded_using); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_are_sucessfully_reloaded_using); __pyx_t_11 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2092, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
2093: " reloaded using ~.externals.joblib`!")
+2094: except :
__Pyx_TraceLine(2094,0,__PYX_ERR(0, 2094, __pyx_L7_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.load_serialized_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_6, &__pyx_t_3) < 0) __PYX_ERR(0, 2094, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_3);
+2095: if verbose >2:
__Pyx_TraceLine(2095,0,__PYX_ERR(0, 2095, __pyx_L7_except_error)) __pyx_t_7 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2095, __pyx_L7_except_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 2095, __pyx_L7_except_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { /* … */ }
+2096: print(f"Nothing to reload. It's seems data from {_filename!r}"
__Pyx_TraceLine(2096,0,__PYX_ERR(0, 2096, __pyx_L7_except_error)) __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2096, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Nothing_to_reload_It_s_seems_dat); __pyx_t_4 += 40; __Pyx_GIVEREF(__pyx_kp_u_Nothing_to_reload_It_s_seems_dat); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Nothing_to_reload_It_s_seems_dat); __pyx_t_9 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v__filename), __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2096, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_are_not_dumped_using_external_j); __pyx_t_4 += 46; __Pyx_GIVEREF(__pyx_kp_u_are_not_dumped_using_external_j); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u_are_not_dumped_using_external_j); __pyx_t_9 = __Pyx_PyUnicode_Join(__pyx_t_7, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2096, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2096, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2097: " are not dumped using ~external.joblib module!")
2098:
+2099: with open(filename, 'rb') as tod:
__Pyx_TraceLine(2099,0,__PYX_ERR(0, 2099, __pyx_L7_except_error)) /*with:*/ { __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2099, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_filename); __Pyx_GIVEREF(__pyx_v_filename); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_filename)) __PYX_ERR(0, 2099, __pyx_L7_except_error); __Pyx_INCREF(__pyx_n_u_rb); __Pyx_GIVEREF(__pyx_n_u_rb); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_n_u_rb)) __PYX_ERR(0, 2099, __pyx_L7_except_error); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2099, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_16 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_exit); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 2099, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_9, __pyx_n_s_enter); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2099, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2099, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = __pyx_t_7; __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /*try:*/ { { /*try:*/ { __pyx_v_tod = __pyx_t_10; __pyx_t_10 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L28_try_end; __pyx_L21_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.load_serialized_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_7, &__pyx_t_9) < 0) __PYX_ERR(0, 2099, __pyx_L23_except_error) __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_9); __pyx_t_12 = PyTuple_Pack(3, __pyx_t_10, __pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2099, __pyx_L23_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_12, NULL); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2099, __pyx_L23_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_20); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; if (__pyx_t_1 < 0) __PYX_ERR(0, 2099, __pyx_L23_except_error) __pyx_t_2 = (!__pyx_t_1); if (unlikely(__pyx_t_2)) { __Pyx_GIVEREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ErrRestoreWithState(__pyx_t_10, __pyx_t_7, __pyx_t_9); __pyx_t_10 = 0; __pyx_t_7 = 0; __pyx_t_9 = 0; __PYX_ERR(0, 2099, __pyx_L23_except_error) } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L22_exception_handled; } __pyx_L23_except_error:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); goto __pyx_L7_except_error; __pyx_L22_exception_handled:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_L28_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_16) { __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 2099, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } goto __pyx_L20; } __pyx_L20:; } goto __pyx_L32; __pyx_L15_error:; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L7_except_error; __pyx_L32:; }
+2100: data= pickle.load (tod)
__Pyx_TraceLine(2100,0,__PYX_ERR(0, 2100, __pyx_L21_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_pickle); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2100, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_load); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2100, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_tod}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2100, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_10); __pyx_t_10 = 0;
2101:
+2102: if verbose >2: print(f"Data from `{_filename!r} are well"
__Pyx_TraceLine(2102,0,__PYX_ERR(0, 2102, __pyx_L7_except_error)) __pyx_t_9 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2102, __pyx_L7_except_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2102, __pyx_L7_except_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_2) { __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2102, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Data_from_2); __pyx_t_4 += 11; __Pyx_GIVEREF(__pyx_kp_u_Data_from_2); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Data_from_2); __pyx_t_7 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v__filename), __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2102, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_are_well_deserialized_using_Pyt); __pyx_t_4 += 52; __Pyx_GIVEREF(__pyx_kp_u_are_well_deserialized_using_Pyt); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u_are_well_deserialized_using_Pyt); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_9, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2102, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2102, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L6_exception_handled; }
2103: " deserialized using Python pickle module.`!")
2104:
+2105: is_none = data is None
__Pyx_TraceLine(2105,0,__PYX_ERR(0, 2105, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_data == Py_None); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_is_none = __pyx_t_3; __pyx_t_3 = 0;
+2106: if verbose > 0:
__Pyx_TraceLine(2106,0,__PYX_ERR(0, 2106, __pyx_L1_error)) __pyx_t_3 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2106, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+2107: if is_none :
__Pyx_TraceLine(2107,0,__PYX_ERR(0, 2107, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_is_none); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2107, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L35; }
+2108: print("Unable to deserialize data. Please check your file.")
__Pyx_TraceLine(2108,0,__PYX_ERR(0, 2108, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_tuple__116, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__116 = PyTuple_Pack(1, __pyx_kp_u_Unable_to_deserialize_data_Pleas); if (unlikely(!__pyx_tuple__116)) __PYX_ERR(0, 2108, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__116); __Pyx_GIVEREF(__pyx_tuple__116);
+2109: else : print(f"Data from {_filename} have been sucessfully reloaded.")
__Pyx_TraceLine(2109,0,__PYX_ERR(0, 2109, __pyx_L1_error)) /*else*/ { __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Data_from); __pyx_t_4 += 10; __Pyx_GIVEREF(__pyx_kp_u_Data_from); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Data_from); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v__filename, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u_have_been_sucessfully_reloaded); __pyx_t_4 += 32; __Pyx_GIVEREF(__pyx_kp_u_have_been_sucessfully_reloaded); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_have_been_sucessfully_reloaded); __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L35:;
2110:
+2111: return data
__Pyx_TraceLine(2111,0,__PYX_ERR(0, 2111, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
2112:
+2113: def save_job(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_79save_job(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_78save_job, " Quick save your job using 'joblib' or persistent Python pickle module.\n \n Parameters \n -----------\n job: Any \n Anything to save, preferabaly a models in dict \n \n savefile: str, or path-like object \n name of file to store the model\n The *file* argument must have a write() method that accepts a\n single bytes argument. It can thus be a file object opened for\n binary writing, an io.BytesIO instance, or any other custom\n object that meets this interface.\n \n append_versions: bool, default =True \n Append the version of Joblib module or Python Pickle module following \n by the scikit-learn, numpy and also pandas versions. This is useful \n to have idea about previous versions for loading file when system or \n modules have been upgraded. This could avoid bottleneck when data \n have been stored for long times and user has forgotten the date and \n versions at the time the file was saved. \n \n append_date: bool, default=True, \n Append the date of the day to the filename. \n \n protocol: int, optional \n The optional *protocol* argument tells the pickler to use the\n given protocol; supported protocols are 0, 1, 2, 3, 4 and 5.\n The default protocol is 4. It was introduced in Python 3.4, and\n is incompatible with previous versions.\n \n Specifying a negative protocol version selects the highest\n protocol version supported. The higher the protocol used, the\n more recent the version of Python needed to read the pickle\n produced.\n \n fix_imports: bool, default=True, \n If *fix_imports* is True and *protocol* is less than 3, pickle\n will try to map the new Python 3 names to the old module names\n used in Python 2, so that the pickle data stream is readable\n with Python 2.\n \n buffer_call_back: int, opti""onal \n If *buffer_callback* is None (the default), buffer views are\n serialized into *file* as part of the pickle stream.\n \n If *buffer_callback* is not None, then it can be called any number\n of times with a buffer view. If the callback returns a false value\n (such as None), the given buffer is out-of-band; otherwise the\n buffer is serialized in-band, i.e. inside the pickle stream.\n \n It is an error if *buffer_callback* is not None and *protocol*\n is None or smaller than 5.\n \n job_kws: dict, \n Additional keywords arguments passed to :func:`joblib.dump`. \n \n Returns\n --------\n savefile: str, \n returns the filename\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_79save_job = {"save_job", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_79save_job, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_78save_job}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_79save_job(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_job = 0; PyObject *__pyx_v_savefile = 0; PyObject *__pyx_v_protocol = 0; PyObject *__pyx_v_append_versions = 0; PyObject *__pyx_v_append_date = 0; PyObject *__pyx_v_fix_imports = 0; PyObject *__pyx_v_buffer_callback = 0; PyObject *__pyx_v_job_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("save_job (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_job_kws = PyDict_New(); if (unlikely(!__pyx_v_job_kws)) return NULL; __Pyx_GOTREF(__pyx_v_job_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_job,&__pyx_n_s_savefile,&__pyx_n_s_protocol,&__pyx_n_s_append_versions,&__pyx_n_s_append_date,&__pyx_n_s_fix_imports,&__pyx_n_s_buffer_callback,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; /* … */ /* function exit code */ __Pyx_DECREF(__pyx_v_job_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_78save_job(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_job, PyObject *__pyx_v_savefile, PyObject *__pyx_v_protocol, PyObject *__pyx_v_append_versions, PyObject *__pyx_v_append_date, PyObject *__pyx_v_fix_imports, PyObject *__pyx_v_buffer_callback, PyObject *__pyx_v_job_kws) { PyObject *__pyx_v_remove_extension = 0; PyObject *__pyx_v_sklearn = NULL; PyObject *__pyx_v_versions = NULL; PyObject *__pyx_v_date = NULL; PyObject *__pyx_v_ex = NULL; PyObject *__pyx_v_wfile = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__117) __Pyx_TraceCall("save_job", __pyx_f[0], 2113, 0, __PYX_ERR(0, 2113, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_savefile); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils.save_job", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_remove_extension); __Pyx_XDECREF(__pyx_v_sklearn); __Pyx_XDECREF(__pyx_v_versions); __Pyx_XDECREF(__pyx_v_date); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XDECREF(__pyx_v_wfile); __Pyx_XDECREF(__pyx_v_savefile); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__403 = PyTuple_Pack(15, __pyx_n_s_job, __pyx_n_s_savefile, __pyx_n_s_protocol, __pyx_n_s_append_versions, __pyx_n_s_append_date, __pyx_n_s_fix_imports, __pyx_n_s_buffer_callback, __pyx_n_s_job_kws, __pyx_n_s_remove_extension, __pyx_n_s_remove_extension, __pyx_n_s_sklearn, __pyx_n_s_versions, __pyx_n_s_date, __pyx_n_s_ex, __pyx_n_s_wfile); if (unlikely(!__pyx_tuple__403)) __PYX_ERR(0, 2113, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__403); __Pyx_GIVEREF(__pyx_tuple__403); /* … */ __Pyx_TraceLine(2113,0,__PYX_ERR(0, 2113, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* … */ __Pyx_TraceLine(2113,0,__PYX_ERR(0, 2113, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_79save_job, 0, __pyx_n_s_save_job, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__117)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_save_job, __pyx_t_2) < 0) __PYX_ERR(0, 2113, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__117 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__403, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_save_job, 2113, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__117)) __PYX_ERR(0, 2113, __pyx_L1_error)
2114: job ,
2115: savefile ,* ,
+2116: protocol =None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); /* … */ __Pyx_TraceLine(2116,0,__PYX_ERR(0, 2116, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_protocol, Py_None) < 0) __PYX_ERR(0, 2113, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_append_versions, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 2113, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_append_date, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 2113, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_fix_imports, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 2113, __pyx_L1_error)
+2117: append_versions=True,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+2118: append_date=True,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+2119: fix_imports= True,
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+2120: buffer_callback = None,
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_job)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2113, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savefile)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2113, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("save_job", 1, 2, 2, 1); __PYX_ERR(0, 2113, __pyx_L3_error) } } if (kw_args > 0 && (kw_args <= 5)) { Py_ssize_t index; for (index = 2; index < 7 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2113, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_job_kws, values + 0, kwd_pos_args, "save_job") < 0)) __PYX_ERR(0, 2113, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_job = values[0]; __pyx_v_savefile = values[1]; __pyx_v_protocol = values[2]; __pyx_v_append_versions = values[3]; __pyx_v_append_date = values[4]; __pyx_v_fix_imports = values[5]; __pyx_v_buffer_callback = values[6]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("save_job", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 2113, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_job_kws); __pyx_v_job_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.save_job", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_78save_job(__pyx_self, __pyx_v_job, __pyx_v_savefile, __pyx_v_protocol, __pyx_v_append_versions, __pyx_v_append_date, __pyx_v_fix_imports, __pyx_v_buffer_callback, __pyx_v_job_kws); /* … */ __Pyx_TraceLine(2120,0,__PYX_ERR(0, 2120, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_buffer_callback, Py_None) < 0) __PYX_ERR(0, 2113, __pyx_L1_error)
2121: **job_kws
2122: ):
2123: """ Quick save your job using 'joblib' or persistent Python pickle module.
2124:
2125: Parameters
2126: -----------
2127: job: Any
2128: Anything to save, preferabaly a models in dict
2129:
2130: savefile: str, or path-like object
2131: name of file to store the model
2132: The *file* argument must have a write() method that accepts a
2133: single bytes argument. It can thus be a file object opened for
2134: binary writing, an io.BytesIO instance, or any other custom
2135: object that meets this interface.
2136:
2137: append_versions: bool, default =True
2138: Append the version of Joblib module or Python Pickle module following
2139: by the scikit-learn, numpy and also pandas versions. This is useful
2140: to have idea about previous versions for loading file when system or
2141: modules have been upgraded. This could avoid bottleneck when data
2142: have been stored for long times and user has forgotten the date and
2143: versions at the time the file was saved.
2144:
2145: append_date: bool, default=True,
2146: Append the date of the day to the filename.
2147:
2148: protocol: int, optional
2149: The optional *protocol* argument tells the pickler to use the
2150: given protocol; supported protocols are 0, 1, 2, 3, 4 and 5.
2151: The default protocol is 4. It was introduced in Python 3.4, and
2152: is incompatible with previous versions.
2153:
2154: Specifying a negative protocol version selects the highest
2155: protocol version supported. The higher the protocol used, the
2156: more recent the version of Python needed to read the pickle
2157: produced.
2158:
2159: fix_imports: bool, default=True,
2160: If *fix_imports* is True and *protocol* is less than 3, pickle
2161: will try to map the new Python 3 names to the old module names
2162: used in Python 2, so that the pickle data stream is readable
2163: with Python 2.
2164:
2165: buffer_call_back: int, optional
2166: If *buffer_callback* is None (the default), buffer views are
2167: serialized into *file* as part of the pickle stream.
2168:
2169: If *buffer_callback* is not None, then it can be called any number
2170: of times with a buffer view. If the callback returns a false value
2171: (such as None), the given buffer is out-of-band; otherwise the
2172: buffer is serialized in-band, i.e. inside the pickle stream.
2173:
2174: It is an error if *buffer_callback* is not None and *protocol*
2175: is None or smaller than 5.
2176:
2177: job_kws: dict,
2178: Additional keywords arguments passed to :func:`joblib.dump`.
2179:
2180: Returns
2181: --------
2182: savefile: str,
2183: returns the filename
2184: """
+2185: def remove_extension(fn, ex):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_8save_job_1remove_extension(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_8save_job_remove_extension, "Remove extension either joblib or pickle "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_8save_job_1remove_extension = {"remove_extension", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_8save_job_1remove_extension, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_8save_job_remove_extension}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_8save_job_1remove_extension(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_fn = 0; PyObject *__pyx_v_ex = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("remove_extension (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_fn,&__pyx_n_s_ex,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fn)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2185, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ex)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2185, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("remove_extension", 1, 2, 2, 1); __PYX_ERR(0, 2185, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "remove_extension") < 0)) __PYX_ERR(0, 2185, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_fn = values[0]; __pyx_v_ex = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("remove_extension", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 2185, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.save_job.remove_extension", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_8save_job_remove_extension(__pyx_self, __pyx_v_fn, __pyx_v_ex); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_8save_job_remove_extension(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_fn, PyObject *__pyx_v_ex) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("remove_extension", __pyx_f[0], 2185, 0, __PYX_ERR(0, 2185, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.save_job.remove_extension", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__118 = PyTuple_Pack(2, __pyx_n_s_fn, __pyx_n_s_ex); if (unlikely(!__pyx_tuple__118)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__118); __Pyx_GIVEREF(__pyx_tuple__118); /* … */ __Pyx_TraceLine(2185,0,__PYX_ERR(0, 2185, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_8save_job_1remove_extension, 0, __pyx_n_s_save_job_locals_remove_extension, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__119)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_remove_extension = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__119 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__118, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_remove_extension, 2185, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__119)) __PYX_ERR(0, 2185, __pyx_L1_error)
2186: """Remove extension either joblib or pickle """
+2187: return fn.replace (ex, '')
__Pyx_TraceLine(2187,0,__PYX_ERR(0, 2187, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_fn, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_ex, __pyx_kp_u__22}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2188:
+2189: import sklearn
__Pyx_TraceLine(2189,0,__PYX_ERR(0, 2189, __pyx_L1_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_sklearn, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_sklearn = __pyx_t_1; __pyx_t_1 = 0;
2190:
+2191: versions = 'sklearn_v{0}.numpy_v{1}.pandas_v{2}'.format(
__Pyx_TraceLine(2191,0,__PYX_ERR(0, 2191, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_sklearn_v_0_numpy_v_1_pandas_v_2, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+2192: sklearn.__version__, np.__version__, pd.__version__)
__Pyx_TraceLine(2192,0,__PYX_ERR(0, 2192, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_sklearn, __pyx_n_s_version); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_version); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_version); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2192, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_t_3, __pyx_t_5, __pyx_t_6}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 3+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2191, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_versions = __pyx_t_1; __pyx_t_1 = 0;
+2193: date = datetime.datetime.now()
__Pyx_TraceLine(2193,0,__PYX_ERR(0, 2193, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_now); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2193, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_date = __pyx_t_1; __pyx_t_1 = 0;
2194:
+2195: savefile =str(savefile)
__Pyx_TraceLine(2195,0,__PYX_ERR(0, 2195, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_savefile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2195, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_savefile, __pyx_t_1); __pyx_t_1 = 0;
+2196: if (
__Pyx_TraceLine(2196,0,__PYX_ERR(0, 2196, __pyx_L1_error)) if (__pyx_t_8) { /* … */ }
+2197: '.joblib' in savefile or '.pkl' in savefile
__Pyx_TraceLine(2197,0,__PYX_ERR(0, 2197, __pyx_L1_error)) __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u_joblib_2, __pyx_v_savefile, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2197, __pyx_L1_error) if (!__pyx_t_9) { } else { __pyx_t_8 = __pyx_t_9; goto __pyx_L4_bool_binop_done; } __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u_pkl, __pyx_v_savefile, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2197, __pyx_L1_error) __pyx_t_8 = __pyx_t_9; __pyx_L4_bool_binop_done:;
2198: ):
+2199: ex = '.joblib' if savefile.find('.joblib')>=0 else '.pkl'
__Pyx_TraceLine(2199,0,__PYX_ERR(0, 2199, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_savefile, __pyx_n_s_find); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_kp_u_joblib_2}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_8) { __Pyx_INCREF(__pyx_kp_u_joblib_2); __pyx_t_1 = __pyx_kp_u_joblib_2; } else { __Pyx_INCREF(__pyx_kp_u_pkl); __pyx_t_1 = __pyx_kp_u_pkl; } __pyx_v_ex = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2200: savefile = remove_extension(savefile , ex )
__Pyx_TraceLine(2200,0,__PYX_ERR(0, 2200, __pyx_L1_error)) __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_8save_job_remove_extension(__pyx_v_remove_extension, __pyx_v_savefile, __pyx_v_ex); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_savefile, __pyx_t_1); __pyx_t_1 = 0;
2201:
+2202: if append_date:
__Pyx_TraceLine(2202,0,__PYX_ERR(0, 2202, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_append_date); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2202, __pyx_L1_error) if (__pyx_t_8) { /* … */ }
+2203: savefile +=".{}".format(date)
__Pyx_TraceLine(2203,0,__PYX_ERR(0, 2203, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__120, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_date}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_savefile, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_savefile, __pyx_t_6); __pyx_t_6 = 0;
2204:
+2205: if append_versions :
__Pyx_TraceLine(2205,0,__PYX_ERR(0, 2205, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_append_versions); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2205, __pyx_L1_error) if (__pyx_t_8) { /* … */ }
+2206: savefile += ".{}"+ versions
__Pyx_TraceLine(2206,0,__PYX_ERR(0, 2206, __pyx_L1_error)) __pyx_t_6 = PyNumber_Add(__pyx_kp_u__120, __pyx_v_versions); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_savefile, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2206, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_savefile, __pyx_t_1); __pyx_t_1 = 0;
+2207: try :
__Pyx_TraceLine(2207,0,__PYX_ERR(0, 2207, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L13_try_end; __pyx_L8_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L10_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L1_error; __pyx_L9_exception_handled:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); __pyx_L13_try_end:; }
+2208: if append_versions:
__Pyx_TraceLine(2208,0,__PYX_ERR(0, 2208, __pyx_L8_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_append_versions); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2208, __pyx_L8_error) if (__pyx_t_8) { /* … */ }
+2209: savefile += ".joblib_v{}.".format(joblib.__version__)
__Pyx_TraceLine(2209,0,__PYX_ERR(0, 2209, __pyx_L8_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_joblib_v, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2209, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_joblib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2209, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_version); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2209, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2209, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_savefile, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2209, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_savefile, __pyx_t_6); __pyx_t_6 = 0;
2210:
+2211: joblib.dump(job, f'{savefile}.joblib', **job_kws)
__Pyx_TraceLine(2211,0,__PYX_ERR(0, 2211, __pyx_L8_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_joblib); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dump); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v_savefile, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_6, __pyx_kp_u_joblib_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_job); __Pyx_GIVEREF(__pyx_v_job); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_job)) __PYX_ERR(0, 2211, __pyx_L8_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5)) __PYX_ERR(0, 2211, __pyx_L8_error); __pyx_t_5 = 0; __pyx_t_5 = PyDict_Copy(__pyx_v_job_kws); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2211, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2212:
+2213: except :
__Pyx_TraceLine(2213,0,__PYX_ERR(0, 2213, __pyx_L10_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.save_job", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 2213, __pyx_L10_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6);
+2214: if append_versions:
__Pyx_TraceLine(2214,0,__PYX_ERR(0, 2214, __pyx_L10_except_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_append_versions); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2214, __pyx_L10_except_error) if (__pyx_t_8) { /* … */ }
+2215: savefile +=".pickle_v{}.pkl".format(pickle.__version__)
__Pyx_TraceLine(2215,0,__PYX_ERR(0, 2215, __pyx_L10_except_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_pickle_v_pkl, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2215, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pickle); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2215, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_version); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2215, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_13}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2215, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_savefile, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2215, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_savefile, __pyx_t_3); __pyx_t_3 = 0;
2216:
+2217: with open(savefile, 'wb') as wfile:
__Pyx_TraceLine(2217,0,__PYX_ERR(0, 2217, __pyx_L10_except_error)) /*with:*/ { __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2217, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_savefile); __Pyx_GIVEREF(__pyx_v_savefile); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_savefile)) __PYX_ERR(0, 2217, __pyx_L10_except_error); __Pyx_INCREF(__pyx_n_u_wb); __Pyx_GIVEREF(__pyx_n_u_wb); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_n_u_wb)) __PYX_ERR(0, 2217, __pyx_L10_except_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2217, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2217, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2217, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_13))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2217, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_t_13 = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_wfile = __pyx_t_13; __pyx_t_13 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; goto __pyx_L31_try_end; __pyx_L24_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.save_job", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_13) < 0) __PYX_ERR(0, 2217, __pyx_L26_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_13); __pyx_t_1 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2217, __pyx_L26_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_1, NULL); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2217, __pyx_L26_except_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_18); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__pyx_t_8 < 0) __PYX_ERR(0, 2217, __pyx_L26_except_error) __pyx_t_9 = (!__pyx_t_8); if (unlikely(__pyx_t_9)) { __Pyx_GIVEREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_3, __pyx_t_13); __pyx_t_4 = 0; __pyx_t_3 = 0; __pyx_t_13 = 0; __PYX_ERR(0, 2217, __pyx_L26_except_error) } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L25_exception_handled; } __pyx_L26_except_error:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L10_except_error; __pyx_L25_exception_handled:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_L31_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_14) { __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2217, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } goto __pyx_L23; } __pyx_L23:; } goto __pyx_L35; __pyx_L18_error:; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L10_except_error; __pyx_L35:; } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L9_exception_handled; }
+2218: pickle.dump( job, wfile, protocol= protocol,
__Pyx_TraceLine(2218,0,__PYX_ERR(0, 2218, __pyx_L24_error)) __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_pickle); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2218, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_dump); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2218, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2218, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_v_job); __Pyx_GIVEREF(__pyx_v_job); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_job)) __PYX_ERR(0, 2218, __pyx_L24_error); __Pyx_INCREF(__pyx_v_wfile); __Pyx_GIVEREF(__pyx_v_wfile); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_wfile)) __PYX_ERR(0, 2218, __pyx_L24_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2218, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_protocol, __pyx_v_protocol) < 0) __PYX_ERR(0, 2218, __pyx_L24_error) /* … */ __Pyx_TraceLine(2218,0,__PYX_ERR(0, 2218, __pyx_L24_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_13, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2218, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2219: fix_imports=fix_imports ,
__Pyx_TraceLine(2219,0,__PYX_ERR(0, 2219, __pyx_L24_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_fix_imports, __pyx_v_fix_imports) < 0) __PYX_ERR(0, 2218, __pyx_L24_error)
+2220: buffer_callback=buffer_callback )
__Pyx_TraceLine(2220,0,__PYX_ERR(0, 2220, __pyx_L24_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_buffer_callback, __pyx_v_buffer_callback) < 0) __PYX_ERR(0, 2218, __pyx_L24_error)
2221:
+2222: return savefile
__Pyx_TraceLine(2222,0,__PYX_ERR(0, 2222, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_savefile); __pyx_r = __pyx_v_savefile; goto __pyx_L0;
2223:
+2224: def fmt_text(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_81fmt_text(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_80fmt_text, "\n Function format text from anomaly features \n \n :param anFeatures: Anomaly features \n :type anFeatures: list or dict\n \n :param title: head lines \n :type title: list\n \n :Example: \n \n >>> from gofast.tools.coreutils import fmt_text\n >>> fmt_text(anFeatures =[1,130, 93,(146,145, 125)])\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_81fmt_text = {"fmt_text", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_81fmt_text, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_80fmt_text}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_81fmt_text(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_anFeatures = 0; PyObject *__pyx_v_title = 0; PyObject *__pyx_v_kwargs = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fmt_text (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL; __Pyx_GOTREF(__pyx_v_kwargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_anFeatures,&__pyx_n_s_title,0}; PyObject* values[2] = {0,0}; /* … */ /* function exit code */ __Pyx_DECREF(__pyx_v_kwargs); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_80fmt_text(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_anFeatures, PyObject *__pyx_v_title, PyObject *__pyx_v_kwargs) { PyObject *__pyx_v_inline = NULL; PyObject *__pyx_v_mlabel = NULL; PyObject *__pyx_v_line = NULL; PyObject *__pyx_v_tem_head = NULL; PyObject *__pyx_v_newF = NULL; PyObject *__pyx_v_keys = NULL; PyObject *__pyx_v_items = NULL; PyObject *__pyx_v_rrpos = NULL; PyObject *__pyx_v_rank = NULL; PyObject *__pyx_v_pos = NULL; PyObject *__pyx_v_strfeatures = NULL; PyObject *__pyx_9genexpr29__pyx_v_i = NULL; PyObject *__pyx_9genexpr30__pyx_v_i = NULL; PyObject *__pyx_9genexpr31__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__121) __Pyx_TraceCall("fmt_text", __pyx_f[0], 2224, 0, __PYX_ERR(0, 2224, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_anFeatures); __Pyx_INCREF(__pyx_v_title); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_18); __Pyx_XDECREF(__pyx_t_19); __Pyx_AddTraceback("gofast.tools.coreutils.fmt_text", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_inline); __Pyx_XDECREF(__pyx_v_mlabel); __Pyx_XDECREF(__pyx_v_line); __Pyx_XDECREF(__pyx_v_tem_head); __Pyx_XDECREF(__pyx_v_newF); __Pyx_XDECREF(__pyx_v_keys); __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_rrpos); __Pyx_XDECREF(__pyx_v_rank); __Pyx_XDECREF(__pyx_v_pos); __Pyx_XDECREF(__pyx_v_strfeatures); __Pyx_XDECREF(__pyx_9genexpr29__pyx_v_i); __Pyx_XDECREF(__pyx_9genexpr30__pyx_v_i); __Pyx_XDECREF(__pyx_9genexpr31__pyx_v_i); __Pyx_XDECREF(__pyx_v_anFeatures); __Pyx_XDECREF(__pyx_v_title); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__404 = PyTuple_Pack(17, __pyx_n_s_anFeatures, __pyx_n_s_title, __pyx_n_s_kwargs, __pyx_n_s_inline, __pyx_n_s_mlabel, __pyx_n_s_line, __pyx_n_s_tem_head, __pyx_n_s_newF, __pyx_n_s_keys, __pyx_n_s_items, __pyx_n_s_rrpos, __pyx_n_s_rank, __pyx_n_s_pos, __pyx_n_s_strfeatures, __pyx_n_s_i, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__404)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__404); __Pyx_GIVEREF(__pyx_tuple__404); /* … */ __Pyx_TraceLine(2224,0,__PYX_ERR(0, 2224, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_81fmt_text, 0, __pyx_n_s_fmt_text, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__121)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__226); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fmt_text, __pyx_t_2) < 0) __PYX_ERR(0, 2224, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__121 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__404, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fmt_text, 2224, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__121)) __PYX_ERR(0, 2224, __pyx_L1_error)
+2225: anFeatures=None,
values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+2226: title = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_anFeatures); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2224, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_title); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2224, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kwargs, values + 0, kwd_pos_args, "fmt_text") < 0)) __PYX_ERR(0, 2224, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_anFeatures = values[0]; __pyx_v_title = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fmt_text", 0, 0, 2, __pyx_nargs); __PYX_ERR(0, 2224, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; __Pyx_AddTraceback("gofast.tools.coreutils.fmt_text", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_80fmt_text(__pyx_self, __pyx_v_anFeatures, __pyx_v_title, __pyx_v_kwargs);
2227: **kwargs) :
2228: """
2229: Function format text from anomaly features
2230:
2231: :param anFeatures: Anomaly features
2232: :type anFeatures: list or dict
2233:
2234: :param title: head lines
2235: :type title: list
2236:
2237: :Example:
2238:
2239: >>> from gofast.tools.coreutils import fmt_text
2240: >>> fmt_text(anFeatures =[1,130, 93,(146,145, 125)])
2241:
2242: """
+2243: if title is None:
__Pyx_TraceLine(2243,0,__PYX_ERR(0, 2243, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_title == Py_None); if (__pyx_t_1) { /* … */ }
+2244: title = ['Ranking', 'rho(Ω.m)', 'position pk(m)', 'rho range(Ω.m)']
__Pyx_TraceLine(2244,0,__PYX_ERR(0, 2244, __pyx_L1_error)) __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_u_Ranking); __Pyx_GIVEREF(__pyx_n_u_Ranking); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_Ranking)) __PYX_ERR(0, 2244, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_rho_m); __Pyx_GIVEREF(__pyx_kp_u_rho_m); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u_rho_m)) __PYX_ERR(0, 2244, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_position_pk_m); __Pyx_GIVEREF(__pyx_kp_u_position_pk_m); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_position_pk_m)) __PYX_ERR(0, 2244, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_rho_range_m); __Pyx_GIVEREF(__pyx_kp_u_rho_range_m); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 3, __pyx_kp_u_rho_range_m)) __PYX_ERR(0, 2244, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_title, __pyx_t_2); __pyx_t_2 = 0;
+2245: inline =kwargs.pop('inline', '-')
__Pyx_TraceLine(2245,0,__PYX_ERR(0, 2245, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_u_inline, __pyx_kp_u__29); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2245, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_inline = __pyx_t_2; __pyx_t_2 = 0;
+2246: mlabel =kwargs.pop('mlabels', 100)
__Pyx_TraceLine(2246,0,__PYX_ERR(0, 2246, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_Pop(__pyx_v_kwargs, __pyx_n_u_mlabels, __pyx_int_100); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2246, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_mlabel = __pyx_t_2; __pyx_t_2 = 0;
+2247: line = inline * int(mlabel)
__Pyx_TraceLine(2247,0,__PYX_ERR(0, 2247, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_mlabel); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Multiply(__pyx_v_inline, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_line = __pyx_t_3; __pyx_t_3 = 0;
2248:
2249: #--------------------header ----------------------------------------
+2250: print(line)
__Pyx_TraceLine(2250,0,__PYX_ERR(0, 2250, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2250, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2251: tem_head ='|'.join(['{:^15}'.format(i) for i in title[:-1]])
__Pyx_TraceLine(2251,0,__PYX_ERR(0, 2251, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_title, 0, -1L, NULL, NULL, &__pyx_slice__64, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2251, __pyx_L6_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2251, __pyx_L6_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2251, __pyx_L6_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2251, __pyx_L6_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2251, __pyx_L6_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2251, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_9genexpr29__pyx_v_i, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_15, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_9genexpr29__pyx_v_i}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 2251, __pyx_L6_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_9genexpr29__pyx_v_i); __pyx_9genexpr29__pyx_v_i = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr29__pyx_v_i); __pyx_9genexpr29__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __pyx_t_4 = PyUnicode_Join(__pyx_kp_u__122, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_tem_head = __pyx_t_4; __pyx_t_4 = 0;
+2252: tem_head +='|{:^45}'.format(title[-1])
__Pyx_TraceLine(2252,0,__PYX_ERR(0, 2252, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_45, __pyx_n_s_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_title, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_2}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_tem_head, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_tem_head, __pyx_t_3); __pyx_t_3 = 0;
+2253: print(tem_head)
__Pyx_TraceLine(2253,0,__PYX_ERR(0, 2253, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_tem_head); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2253, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2254: print(line)
__Pyx_TraceLine(2254,0,__PYX_ERR(0, 2254, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_line); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2254, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2255: #-----------------------end header----------------------------------
+2256: newF =[]
__Pyx_TraceLine(2256,0,__PYX_ERR(0, 2256, __pyx_L1_error)) __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_newF = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+2257: if isinstance(anFeatures, dict):
__Pyx_TraceLine(2257,0,__PYX_ERR(0, 2257, __pyx_L1_error)) __pyx_t_1 = PyDict_Check(__pyx_v_anFeatures); if (__pyx_t_1) { /* … */ goto __pyx_L11; }
+2258: for keys, items in anFeatures.items():
__Pyx_TraceLine(2258,0,__PYX_ERR(0, 2258, __pyx_L1_error)) __pyx_t_5 = 0; if (unlikely(__pyx_v_anFeatures == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 2258, __pyx_L1_error) } __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_anFeatures, 0, __pyx_n_s_items, (&__pyx_t_10), (&__pyx_t_9)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_4; __pyx_t_4 = 0; while (1) { __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_10, &__pyx_t_5, &__pyx_t_4, &__pyx_t_2, NULL, __pyx_t_9); if (unlikely(__pyx_t_11 == 0)) break; if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 2258, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_2); __Pyx_XDECREF_SET(__pyx_v_keys, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_items, __pyx_t_2); __pyx_t_2 = 0;
+2259: rrpos=keys.replace('_pk', '')
__Pyx_TraceLine(2259,0,__PYX_ERR(0, 2259, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_keys, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__123, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_rrpos, __pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_tuple__123 = PyTuple_Pack(2, __pyx_n_u_pk, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 2259, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__123); __Pyx_GIVEREF(__pyx_tuple__123);
+2260: rank=rrpos[0]
__Pyx_TraceLine(2260,0,__PYX_ERR(0, 2260, __pyx_L1_error)) __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_rrpos, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2260, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_rank, __pyx_t_4); __pyx_t_4 = 0;
+2261: pos =rrpos[1:]
__Pyx_TraceLine(2261,0,__PYX_ERR(0, 2261, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_rrpos, 1, 0, NULL, NULL, &__pyx_slice__124, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_pos, __pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_slice__124 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__124)) __PYX_ERR(0, 2261, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__124); __Pyx_GIVEREF(__pyx_slice__124);
+2262: newF.append([rank, min(items), pos, items])
__Pyx_TraceLine(2262,0,__PYX_ERR(0, 2262, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_rank); __Pyx_GIVEREF(__pyx_v_rank); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_rank)) __PYX_ERR(0, 2262, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_4)) __PYX_ERR(0, 2262, __pyx_L1_error); __Pyx_INCREF(__pyx_v_pos); __Pyx_GIVEREF(__pyx_v_pos); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_v_pos)) __PYX_ERR(0, 2262, __pyx_L1_error); __Pyx_INCREF(__pyx_v_items); __Pyx_GIVEREF(__pyx_v_items); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 3, __pyx_v_items)) __PYX_ERR(0, 2262, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_newF, __pyx_t_2); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 2262, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2263:
+2264: elif isinstance(anFeatures, list):
__Pyx_TraceLine(2264,0,__PYX_ERR(0, 2264, __pyx_L1_error)) __pyx_t_1 = PyList_Check(__pyx_v_anFeatures); if (__pyx_t_1) { /* … */ } __pyx_L11:;
+2265: newF =[anFeatures]
__Pyx_TraceLine(2265,0,__PYX_ERR(0, 2265, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_anFeatures); __Pyx_GIVEREF(__pyx_v_anFeatures); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_anFeatures)) __PYX_ERR(0, 2265, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_newF, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
2266:
2267:
+2268: for anFeatures in newF:
__Pyx_TraceLine(2268,0,__PYX_ERR(0, 2268, __pyx_L1_error)) __pyx_t_3 = __pyx_v_newF; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2268, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 2268, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF_SET(__pyx_v_anFeatures, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(2268,0,__PYX_ERR(0, 2268, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2269: strfeatures ='|'.join(['{:^15}'.format(str(i)) \
__Pyx_TraceLine(2269,0,__PYX_ERR(0, 2269, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2269, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(2269,0,__PYX_ERR(0, 2269, __pyx_L18_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_15, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2269, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_13 = __Pyx_PyObject_Str(__pyx_9genexpr30__pyx_v_i); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2269, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_t_13}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2269, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 2269, __pyx_L18_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(2269,0,__PYX_ERR(0, 2269, __pyx_L1_error)) __pyx_t_7 = PyUnicode_Join(__pyx_kp_u__122, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_strfeatures, __pyx_t_7); __pyx_t_7 = 0;
+2270: for i in anFeatures[:-1]])
__Pyx_TraceLine(2270,0,__PYX_ERR(0, 2270, __pyx_L18_error)) __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_anFeatures, 0, -1L, NULL, NULL, &__pyx_slice__64, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2270, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_4); if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { __pyx_t_7 = __pyx_t_4; __Pyx_INCREF(__pyx_t_7); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2270, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2270, __pyx_L18_error) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2270, __pyx_L18_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2270, __pyx_L18_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2270, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2270, __pyx_L18_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2270, __pyx_L18_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2270, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_6(__pyx_t_7); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2270, __pyx_L18_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_9genexpr30__pyx_v_i, __pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(2270,0,__PYX_ERR(0, 2270, __pyx_L18_error)) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_9genexpr30__pyx_v_i); __pyx_9genexpr30__pyx_v_i = 0; goto __pyx_L22_exit_scope; __pyx_L18_error:; __Pyx_XDECREF(__pyx_9genexpr30__pyx_v_i); __pyx_9genexpr30__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L22_exit_scope:; } /* exit inner scope */
+2271: try :
__Pyx_TraceLine(2271,0,__PYX_ERR(0, 2271, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L25_except_error:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L1_error; __pyx_L24_exception_handled:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_L30_try_end:; }
+2272: iter(anFeatures[-1])
__Pyx_TraceLine(2272,0,__PYX_ERR(0, 2272, __pyx_L23_error)) __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_anFeatures, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2272, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2272, __pyx_L23_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2273: except :
__Pyx_TraceLine(2273,0,__PYX_ERR(0, 2273, __pyx_L25_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.fmt_text", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_13) < 0) __PYX_ERR(0, 2273, __pyx_L25_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_13);
+2274: strfeatures +='|{:^45}'.format(str(anFeatures[-1]))
__Pyx_TraceLine(2274,0,__PYX_ERR(0, 2274, __pyx_L25_except_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_45, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2274, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_anFeatures, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2274, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_18 = __Pyx_PyObject_Str(__pyx_t_14); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2274, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_t_18}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2274, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_v_strfeatures, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2274, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_strfeatures, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L24_exception_handled; }
2275: else :
+2276: strfeatures += '|{:^45}'.format(
__Pyx_TraceLine(2276,0,__PYX_ERR(0, 2276, __pyx_L25_except_error)) /*else:*/ { __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_45, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2276, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_7); /* … */ __Pyx_TraceLine(2276,0,__PYX_ERR(0, 2276, __pyx_L25_except_error)) __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_strfeatures, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2276, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_strfeatures, __pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; goto __pyx_L30_try_end; __pyx_L23_error:; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
+2277: ''.join(['{} '.format(str(i)) for i in anFeatures[-1]]))
__Pyx_TraceLine(2277,0,__PYX_ERR(0, 2277, __pyx_L25_except_error)) { /* enter inner scope */ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_anFeatures, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_8); if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) { __pyx_t_13 = __pyx_t_8; __Pyx_INCREF(__pyx_t_13); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2277, __pyx_L33_error) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_13))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2277, __pyx_L33_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_13, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2277, __pyx_L33_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_13); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2277, __pyx_L33_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_5); __Pyx_INCREF(__pyx_t_8); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2277, __pyx_L33_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_6(__pyx_t_13); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2277, __pyx_L33_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_9genexpr31__pyx_v_i, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__125, __pyx_n_s_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_18 = __Pyx_PyObject_Str(__pyx_9genexpr31__pyx_v_i); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_14))) { __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_19)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_19); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_18}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 2277, __pyx_L33_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_9genexpr31__pyx_v_i); __pyx_9genexpr31__pyx_v_i = 0; goto __pyx_L37_exit_scope; __pyx_L33_error:; __Pyx_XDECREF(__pyx_9genexpr31__pyx_v_i); __pyx_9genexpr31__pyx_v_i = 0; goto __pyx_L25_except_error; __pyx_L37_exit_scope:; } /* exit inner scope */ __pyx_t_13 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2277, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_13}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2276, __pyx_L25_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; }
2278:
+2279: print(strfeatures)
__Pyx_TraceLine(2279,0,__PYX_ERR(0, 2279, __pyx_L1_error)) __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_strfeatures); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2279, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+2280: print(line)
__Pyx_TraceLine(2280,0,__PYX_ERR(0, 2280, __pyx_L1_error)) __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_line); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
2281:
2282:
+2283: def wrap_infos (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_83wrap_infos(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_82wrap_infos, "Display info from anomaly details."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_83wrap_infos = {"wrap_infos", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_83wrap_infos, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_82wrap_infos}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_83wrap_infos(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_phrase = 0; PyObject *__pyx_v_value = 0; PyObject *__pyx_v_underline = 0; PyObject *__pyx_v_unit = 0; PyObject *__pyx_v_site_number = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("wrap_infos (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_phrase,&__pyx_n_s_value,&__pyx_n_s_underline,&__pyx_n_s_unit,&__pyx_n_s_site_number,0}; PyObject* values[5] = {0,0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__22))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__29))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__22))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__22))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_phrase)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2283, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2283, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_underline); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2283, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_unit); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2283, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_site_number); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2283, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "wrap_infos") < 0)) __PYX_ERR(0, 2283, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_phrase = values[0]; __pyx_v_value = values[1]; __pyx_v_underline = values[2]; __pyx_v_unit = values[3]; __pyx_v_site_number = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("wrap_infos", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 2283, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.wrap_infos", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_82wrap_infos(__pyx_self, __pyx_v_phrase, __pyx_v_value, __pyx_v_underline, __pyx_v_unit, __pyx_v_site_number, __pyx_v_kws); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_82wrap_infos(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_phrase, PyObject *__pyx_v_value, PyObject *__pyx_v_underline, PyObject *__pyx_v_unit, PyObject *__pyx_v_site_number, PyObject *__pyx_v_kws) { PyObject *__pyx_v_repeat = NULL; PyObject *__pyx_v_intermediate = NULL; PyObject *__pyx_v_begin_phrase_mark = NULL; PyObject *__pyx_v_on = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__126) __Pyx_TraceCall("wrap_infos", __pyx_f[0], 2283, 0, __PYX_ERR(0, 2283, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.wrap_infos", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_repeat); __Pyx_XDECREF(__pyx_v_intermediate); __Pyx_XDECREF(__pyx_v_begin_phrase_mark); __Pyx_XDECREF(__pyx_v_on); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__405 = PyTuple_Pack(10, __pyx_n_s_phrase, __pyx_n_s_value, __pyx_n_s_underline, __pyx_n_s_unit, __pyx_n_s_site_number, __pyx_n_s_kws_2, __pyx_n_s_repeat, __pyx_n_s_intermediate, __pyx_n_s_begin_phrase_mark, __pyx_n_s_on); if (unlikely(!__pyx_tuple__405)) __PYX_ERR(0, 2283, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__405); __Pyx_GIVEREF(__pyx_tuple__405); __pyx_codeobj__126 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__405, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_wrap_infos, 2283, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__126)) __PYX_ERR(0, 2283, __pyx_L1_error) /* … */ __Pyx_TraceLine(2283,0,__PYX_ERR(0, 2283, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_83wrap_infos, 0, __pyx_n_s_wrap_infos, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__126)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2283, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__406); if (PyDict_SetItem(__pyx_d, __pyx_n_s_wrap_infos, __pyx_t_2) < 0) __PYX_ERR(0, 2283, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__406 = PyTuple_Pack(4, ((PyObject*)__pyx_kp_u__22), ((PyObject*)__pyx_kp_u__29), ((PyObject*)__pyx_kp_u__22), ((PyObject*)__pyx_kp_u__22)); if (unlikely(!__pyx_tuple__406)) __PYX_ERR(0, 2283, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__406); __Pyx_GIVEREF(__pyx_tuple__406);
2284: phrase ,
2285: value ='',
2286: underline ='-',
2287: unit ='',
2288: site_number= '',
2289: **kws) :
2290: """Display info from anomaly details."""
2291:
+2292: repeat =kws.pop('repeat', 77)
__Pyx_TraceLine(2292,0,__PYX_ERR(0, 2292, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_repeat, __pyx_int_77); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_repeat = __pyx_t_1; __pyx_t_1 = 0;
+2293: intermediate =kws.pop('inter+', '')
__Pyx_TraceLine(2293,0,__PYX_ERR(0, 2293, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_kp_u_inter, __pyx_kp_u__22); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_intermediate = __pyx_t_1; __pyx_t_1 = 0;
+2294: begin_phrase_mark= kws.pop('begin_phrase', '--|>')
__Pyx_TraceLine(2294,0,__PYX_ERR(0, 2294, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_begin_phrase, __pyx_kp_u__127); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2294, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_begin_phrase_mark = __pyx_t_1; __pyx_t_1 = 0;
+2295: on = kws.pop('on', False)
__Pyx_TraceLine(2295,0,__PYX_ERR(0, 2295, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_on, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_on = __pyx_t_1; __pyx_t_1 = 0;
+2296: if not on: return ''
__Pyx_TraceLine(2296,0,__PYX_ERR(0, 2296, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_on); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2296, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_kp_u__22); __pyx_r = __pyx_kp_u__22; goto __pyx_L0; }
2297: else :
+2298: print(underline * repeat)
__Pyx_TraceLine(2298,0,__PYX_ERR(0, 2298, __pyx_L1_error)) /*else*/ { __pyx_t_1 = PyNumber_Multiply(__pyx_v_underline, __pyx_v_repeat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2299: print('{0} {1:<50}'.format(begin_phrase_mark, phrase),
__Pyx_TraceLine(2299,0,__PYX_ERR(0, 2299, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_1_50, __pyx_n_s_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_v_begin_phrase_mark, __pyx_v_phrase}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* … */ __Pyx_TraceLine(2299,0,__PYX_ERR(0, 2299, __pyx_L1_error)) __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4)) __PYX_ERR(0, 2299, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1)) __PYX_ERR(0, 2299, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5)) __PYX_ERR(0, 2299, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7)) __PYX_ERR(0, 2299, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+2300: '{0:<10} {1}'.format(value, unit),
__Pyx_TraceLine(2300,0,__PYX_ERR(0, 2300, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_10_1, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_v_value, __pyx_v_unit}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
+2301: '{0}'.format(intermediate), "{}".format(site_number))
__Pyx_TraceLine(2301,0,__PYX_ERR(0, 2301, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_2, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_intermediate}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_site_number}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2301, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
+2302: print(underline * repeat )
__Pyx_TraceLine(2302,0,__PYX_ERR(0, 2302, __pyx_L1_error)) __pyx_t_7 = PyNumber_Multiply(__pyx_v_underline, __pyx_v_repeat); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
2303:
2304:
+2305: def reshape(arr , axis = None) :
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_85reshape(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_84reshape, " Detect the array shape and reshape it accordingly, back to the given axis. \n \n :param array: array_like with number of dimension equals to 1 or 2 \n :param axis: axis to reshape back array. If 'axis' is None and \n the number of dimension is greater than 1, it reshapes back array \n to array-like \n \n :returns: New reshaped array \n \n :Example: \n >>> import numpy as np \n >>> from gofast.tools.coreutils import reshape \n >>> array = np.random.randn(50 )\n >>> array.shape\n ... (50,)\n >>> ar1 = reshape(array, 1) \n >>> ar1.shape \n ... (1, 50)\n >>> ar2 =reshape(ar1 , 0) \n >>> ar2.shape \n ... (50, 1)\n >>> ar3 = reshape(ar2, axis = None)\n >>> ar3.shape # goes back to the original array \n >>> ar3.shape \n ... (50,)\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_85reshape = {"reshape", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_85reshape, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_84reshape}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_85reshape(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_axis = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reshape (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_axis,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2305, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_axis); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2305, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "reshape") < 0)) __PYX_ERR(0, 2305, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_axis = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("reshape", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 2305, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.reshape", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_84reshape(__pyx_self, __pyx_v_arr, __pyx_v_axis); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_84reshape(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_axis) { PyObject *__pyx_v_s0 = NULL; PyObject *__pyx_v_s1 = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__128) __Pyx_TraceCall("reshape", __pyx_f[0], 2305, 0, __PYX_ERR(0, 2305, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_arr); __Pyx_INCREF(__pyx_v_axis); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.reshape", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s0); __Pyx_XDECREF(__pyx_v_s1); __Pyx_XDECREF(__pyx_v_arr); __Pyx_XDECREF(__pyx_v_axis); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__407 = PyTuple_Pack(4, __pyx_n_s_arr, __pyx_n_s_axis, __pyx_n_s_s0, __pyx_n_s_s1); if (unlikely(!__pyx_tuple__407)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__407); __Pyx_GIVEREF(__pyx_tuple__407); /* … */ __Pyx_TraceLine(2305,0,__PYX_ERR(0, 2305, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_85reshape, 0, __pyx_n_s_reshape, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__128)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__62); if (PyDict_SetItem(__pyx_d, __pyx_n_s_reshape, __pyx_t_2) < 0) __PYX_ERR(0, 2305, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__128 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__407, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_reshape, 2305, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__128)) __PYX_ERR(0, 2305, __pyx_L1_error)
2306: """ Detect the array shape and reshape it accordingly, back to the given axis.
2307:
2308: :param array: array_like with number of dimension equals to 1 or 2
2309: :param axis: axis to reshape back array. If 'axis' is None and
2310: the number of dimension is greater than 1, it reshapes back array
2311: to array-like
2312:
2313: :returns: New reshaped array
2314:
2315: :Example:
2316: >>> import numpy as np
2317: >>> from gofast.tools.coreutils import reshape
2318: >>> array = np.random.randn(50 )
2319: >>> array.shape
2320: ... (50,)
2321: >>> ar1 = reshape(array, 1)
2322: >>> ar1.shape
2323: ... (1, 50)
2324: >>> ar2 =reshape(ar1 , 0)
2325: >>> ar2.shape
2326: ... (50, 1)
2327: >>> ar3 = reshape(ar2, axis = None)
2328: >>> ar3.shape # goes back to the original array
2329: >>> ar3.shape
2330: ... (50,)
2331:
2332: """
+2333: arr = np.array(arr)
__Pyx_TraceLine(2333,0,__PYX_ERR(0, 2333, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2333, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_1); __pyx_t_1 = 0;
+2334: if arr.ndim > 2 :
__Pyx_TraceLine(2334,0,__PYX_ERR(0, 2334, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_2, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2334, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2334, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_5)) { /* … */ }
+2335: raise ValueError('Expect an array with max dimension equals to 2'
__Pyx_TraceLine(2335,0,__PYX_ERR(0, 2335, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_Expect_an_array_with_max_dimensi); __pyx_t_6 += 51; __Pyx_GIVEREF(__pyx_kp_u_Expect_an_array_with_max_dimensi); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Expect_an_array_with_max_dimensi); /* … */ __Pyx_TraceLine(2335,0,__PYX_ERR(0, 2335, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2335, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 2335, __pyx_L1_error)
+2336: f' but {str(arr.ndim)!r} were given.')
__Pyx_TraceLine(2336,0,__PYX_ERR(0, 2336, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Str(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_were_given); __pyx_t_6 += 12; __Pyx_GIVEREF(__pyx_kp_u_were_given); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_were_given);
2337:
+2338: if axis not in (0 , 1, -1, None):
__Pyx_TraceLine(2338,0,__PYX_ERR(0, 2338, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_axis); __pyx_t_3 = __pyx_v_axis; __pyx_t_8 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_3, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2338, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L5_bool_binop_done; } __pyx_t_8 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_3, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2338, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L5_bool_binop_done; } __pyx_t_8 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_3, __pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2338, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L5_bool_binop_done; } __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2338, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2338, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_8; __pyx_L5_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __pyx_t_5; if (unlikely(__pyx_t_8)) { /* … */ }
+2339: raise ValueError(f'Wrong axis value: {str(axis)!r}')
__Pyx_TraceLine(2339,0,__PYX_ERR(0, 2339, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_axis); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_3), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Wrong_axis_value, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2339, __pyx_L1_error)
2340:
+2341: if axis ==-1:
__Pyx_TraceLine(2341,0,__PYX_ERR(0, 2341, __pyx_L1_error)) __pyx_t_8 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_axis, __pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2341, __pyx_L1_error) if (__pyx_t_8) { /* … */ }
+2342: axis =None
__Pyx_TraceLine(2342,0,__PYX_ERR(0, 2342, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_axis, Py_None);
+2343: if arr.ndim ==1 :
__Pyx_TraceLine(2343,0,__PYX_ERR(0, 2343, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2343, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_8) { /* … */ goto __pyx_L10; }
2344: # ie , axis is None , array is an array-like object
+2345: s0, s1= arr.shape [0], None
__Pyx_TraceLine(2345,0,__PYX_ERR(0, 2345, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = Py_None; __Pyx_INCREF(__pyx_t_1); __pyx_v_s0 = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_s1 = __pyx_t_1; __pyx_t_1 = 0;
2346: else :
+2347: s0, s1 = arr.shape
__Pyx_TraceLine(2347,0,__PYX_ERR(0, 2347, __pyx_L1_error)) /*else*/ { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 2347, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_3)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_2 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_2)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 2347, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L12_unpacking_done; __pyx_L11_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 2347, __pyx_L1_error) __pyx_L12_unpacking_done:; } __pyx_v_s0 = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_s1 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L10:;
+2348: if s1 is None:
__Pyx_TraceLine(2348,0,__PYX_ERR(0, 2348, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_s1 == Py_None); if (__pyx_t_8) { /* … */ }
+2349: return arr.reshape ((1, s0)) if axis == 1 else (arr.reshape (
__Pyx_TraceLine(2349,0,__PYX_ERR(0, 2349, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_8 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_axis, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2349, __pyx_L1_error) if (__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_reshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_1)) __PYX_ERR(0, 2349, __pyx_L1_error); __Pyx_INCREF(__pyx_v_s0); __Pyx_GIVEREF(__pyx_v_s0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_s0)) __PYX_ERR(0, 2349, __pyx_L1_error); __pyx_t_11 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_t_9}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } else { /* … */ __Pyx_TraceLine(2349,0,__PYX_ERR(0, 2349, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_reshape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9);
+2350: (s0, 1)) if axis ==0 else arr )
__Pyx_TraceLine(2350,0,__PYX_ERR(0, 2350, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_axis, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2350, __pyx_L1_error) if (__pyx_t_5) { /* … */ __Pyx_TraceLine(2350,0,__PYX_ERR(0, 2350, __pyx_L1_error)) __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_v_s0); __Pyx_GIVEREF(__pyx_v_s0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_s0)) __PYX_ERR(0, 2350, __pyx_L1_error); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_int_1)) __PYX_ERR(0, 2350, __pyx_L1_error); __pyx_t_12 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_11}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_arr); __pyx_t_2 = __pyx_v_arr; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+2351: try :
__Pyx_TraceLine(2351,0,__PYX_ERR(0, 2351, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L19_try_end; __pyx_L14_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L16_except_error:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L15_exception_handled:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_L19_try_end:; }
+2352: arr = arr.reshape ((s0 if s1==1 else s1, )) if axis is None else (
__Pyx_TraceLine(2352,0,__PYX_ERR(0, 2352, __pyx_L14_error)) __pyx_t_8 = (__pyx_v_axis == Py_None); if (__pyx_t_8) { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_reshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2352, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_s1, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2352, __pyx_L14_error) if (__pyx_t_5) { __Pyx_INCREF(__pyx_v_s0); __pyx_t_9 = __pyx_v_s0; } else { __Pyx_INCREF(__pyx_v_s1); __pyx_t_9 = __pyx_v_s1; } __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2352, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9)) __PYX_ERR(0, 2352, __pyx_L14_error); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_11}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2352, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } else {
+2353: arr.reshape ((1, s0)) if axis==1 else arr.reshape ((s1, 1 ))
__Pyx_TraceLine(2353,0,__PYX_ERR(0, 2353, __pyx_L14_error)) __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_axis, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2353, __pyx_L14_error) if (__pyx_t_5) { __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_reshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2353, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2353, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_int_1)) __PYX_ERR(0, 2353, __pyx_L14_error); __Pyx_INCREF(__pyx_v_s0); __Pyx_GIVEREF(__pyx_v_s0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_s0)) __PYX_ERR(0, 2353, __pyx_L14_error); __pyx_t_12 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_9}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2353, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_reshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2353, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2353, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_s1); __Pyx_GIVEREF(__pyx_v_s1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_s1)) __PYX_ERR(0, 2353, __pyx_L14_error); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_int_1)) __PYX_ERR(0, 2353, __pyx_L14_error); __pyx_t_12 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_9}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2353, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_1); __pyx_t_1 = 0;
2354: )
+2355: except ValueError:
__Pyx_TraceLine(2355,0,__PYX_ERR(0, 2355, __pyx_L16_except_error)) __pyx_t_4 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_4) { __Pyx_ErrRestore(0,0,0); goto __pyx_L15_exception_handled; } goto __pyx_L16_except_error;
2356: # error raises when user mistakes to input the right axis.
2357: # (ValueError: cannot reshape array of size 54 into shape (1,1))
2358: # then return to him the original array
2359: pass
2360:
+2361: return arr
__Pyx_TraceLine(2361,0,__PYX_ERR(0, 2361, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arr); __pyx_r = __pyx_v_arr; goto __pyx_L0;
2362:
2363:
+2364: def ismissing(refarr, arr, fill_value = np.nan, return_index =False):
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_314__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 2364, 0, __PYX_ERR(0, 2364, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_fill_value);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_fill_value);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self)->__pyx_arg_fill_value)) __PYX_ERR(0, 2364, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 2364, __pyx_L1_error);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 2364, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 2364, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_87ismissing(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_86ismissing, " Get the missing values in array-like and fill it to match the length\n of the reference array. \n \n The function makes sense especially for frequency interpollation in the \n 'attenuation band' when using the audio-frequency magnetotelluric methods. \n \n :param arr: array-like- Array to be extended with fill value. It should be \n shorter than the `refarr`. Otherwise it returns the same array `arr` \n :param refarr: array-like- the reference array. It should have a greater \n length than the array \n :param fill_value: float - Value to fill the `arr` to match the length of \n the `refarr`. \n :param return_index: bool or str - array-like, index of the elements element \n in `arr`. Default is ``False``. Any other value should returns the \n mask of existing element in reference array\n \n :returns: array and values missings or indexes in reference array. \n \n :Example: \n \n >>> import numpy as np \n >>> from gofast.tools.coreutils import ismissing\n >>> refreq = np.linspace(7e7, 1e0, 20) # 20 frequencies as reference\n >>> # remove the value between index 7 to 12 and stack again\n >>> freq = np.hstack ((refreq.copy()[:7], refreq.copy()[12:] )) \n >>> f, m = ismissing (refreq, freq)\n >>> f, m \n ...array([7.00000000e+07, 6.63157895e+07, 6.26315791e+07, 5.89473686e+07,\n 5.52631581e+07, 5.15789476e+07, 4.78947372e+07, nan,\n nan, nan, nan, nan,\n 2.57894743e+07, 2.21052638e+07, 1.84210534e+07, 1.47368429e+07,\n 1.10526324e+07, 7.36842195e+06, 3.68421147e+06, 1.00000000e+00])\n >>> m # missing values \n ... array([44210526.68421052, 40526316.21052632, 36842105.73684211,\n 33157895.2631579 , 29473684.78947368])\n >>> _, m_ix = ismissing (refreq, freq, return_index =True)\n >>> m_ix \n ... array([ 7, 8, 9, 10, 11], dtype=int64)\n "" >>> # assert the missing values from reference values \n >>> refreq[m_ix ] # is equal to m \n ... array([44210526.68421052, 40526316.21052632, 36842105.73684211,\n 33157895.2631579 , 29473684.78947368]) \n \n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_87ismissing = {"ismissing", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_87ismissing, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_86ismissing};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_87ismissing(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_refarr = 0;
PyObject *__pyx_v_arr = 0;
PyObject *__pyx_v_fill_value = 0;
PyObject *__pyx_v_return_index = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("ismissing (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_refarr,&__pyx_n_s_arr,&__pyx_n_s_fill_value,&__pyx_n_s_return_index,0};
PyObject* values[4] = {0,0,0,0};
__pyx_defaults4 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_self);
values[2] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_fill_value);
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_refarr)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2364, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2364, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("ismissing", 0, 2, 4, 1); __PYX_ERR(0, 2364, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fill_value);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2364, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_index);
if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2364, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "ismissing") < 0)) __PYX_ERR(0, 2364, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_refarr = values[0];
__pyx_v_arr = values[1];
__pyx_v_fill_value = values[2];
__pyx_v_return_index = values[3];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("ismissing", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 2364, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.ismissing", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_86ismissing(__pyx_self, __pyx_v_refarr, __pyx_v_arr, __pyx_v_fill_value, __pyx_v_return_index);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_86ismissing(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_refarr, PyObject *__pyx_v_arr, PyObject *__pyx_v_fill_value, PyObject *__pyx_v_return_index) {
PyObject *__pyx_v_ref = NULL;
PyObject *__pyx_v_mask = NULL;
PyObject *__pyx_v_miss_values = NULL;
PyObject *__pyx_v_miss_val_or_ix = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__129)
__Pyx_TraceCall("ismissing", __pyx_f[0], 2364, 0, __PYX_ERR(0, 2364, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_fill_value);
__Pyx_INCREF(__pyx_v_return_index);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_AddTraceback("gofast.tools.coreutils.ismissing", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_ref);
__Pyx_XDECREF(__pyx_v_mask);
__Pyx_XDECREF(__pyx_v_miss_values);
__Pyx_XDECREF(__pyx_v_miss_val_or_ix);
__Pyx_XDECREF(__pyx_v_fill_value);
__Pyx_XDECREF(__pyx_v_return_index);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__408 = PyTuple_Pack(8, __pyx_n_s_refarr, __pyx_n_s_arr, __pyx_n_s_fill_value, __pyx_n_s_return_index, __pyx_n_s_ref, __pyx_n_s_mask, __pyx_n_s_miss_values, __pyx_n_s_miss_val_or_ix); if (unlikely(!__pyx_tuple__408)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__408);
__Pyx_GIVEREF(__pyx_tuple__408);
/* … */
__Pyx_TraceLine(2364,0,__PYX_ERR(0, 2364, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_87ismissing, 0, __pyx_n_s_ismissing, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__129)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults4), 1)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_CyFunction_Defaults(__pyx_defaults4, __pyx_t_2)->__pyx_arg_fill_value = __pyx_t_5;
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
__Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_6gofast_5tools_9coreutils_314__defaults__);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_ismissing, __pyx_t_2) < 0) __PYX_ERR(0, 2364, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_codeobj__129 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__408, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_ismissing, 2364, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__129)) __PYX_ERR(0, 2364, __pyx_L1_error)
2365: """ Get the missing values in array-like and fill it to match the length
2366: of the reference array.
2367:
2368: The function makes sense especially for frequency interpollation in the
2369: 'attenuation band' when using the audio-frequency magnetotelluric methods.
2370:
2371: :param arr: array-like- Array to be extended with fill value. It should be
2372: shorter than the `refarr`. Otherwise it returns the same array `arr`
2373: :param refarr: array-like- the reference array. It should have a greater
2374: length than the array
2375: :param fill_value: float - Value to fill the `arr` to match the length of
2376: the `refarr`.
2377: :param return_index: bool or str - array-like, index of the elements element
2378: in `arr`. Default is ``False``. Any other value should returns the
2379: mask of existing element in reference array
2380:
2381: :returns: array and values missings or indexes in reference array.
2382:
2383: :Example:
2384:
2385: >>> import numpy as np
2386: >>> from gofast.tools.coreutils import ismissing
2387: >>> refreq = np.linspace(7e7, 1e0, 20) # 20 frequencies as reference
2388: >>> # remove the value between index 7 to 12 and stack again
2389: >>> freq = np.hstack ((refreq.copy()[:7], refreq.copy()[12:] ))
2390: >>> f, m = ismissing (refreq, freq)
2391: >>> f, m
2392: ...array([7.00000000e+07, 6.63157895e+07, 6.26315791e+07, 5.89473686e+07,
2393: 5.52631581e+07, 5.15789476e+07, 4.78947372e+07, nan,
2394: nan, nan, nan, nan,
2395: 2.57894743e+07, 2.21052638e+07, 1.84210534e+07, 1.47368429e+07,
2396: 1.10526324e+07, 7.36842195e+06, 3.68421147e+06, 1.00000000e+00])
2397: >>> m # missing values
2398: ... array([44210526.68421052, 40526316.21052632, 36842105.73684211,
2399: 33157895.2631579 , 29473684.78947368])
2400: >>> _, m_ix = ismissing (refreq, freq, return_index =True)
2401: >>> m_ix
2402: ... array([ 7, 8, 9, 10, 11], dtype=int64)
2403: >>> # assert the missing values from reference values
2404: >>> refreq[m_ix ] # is equal to m
2405: ... array([44210526.68421052, 40526316.21052632, 36842105.73684211,
2406: 33157895.2631579 , 29473684.78947368])
2407:
2408: """
+2409: return_index = str(return_index).lower()
__Pyx_TraceLine(2409,0,__PYX_ERR(0, 2409, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_return_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_return_index, __pyx_t_1); __pyx_t_1 = 0;
+2410: fill_value = _assert_all_types(fill_value, float, int)
__Pyx_TraceLine(2410,0,__PYX_ERR(0, 2410, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2410, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_v_fill_value, ((PyObject *)(&PyFloat_Type)), ((PyObject *)(&PyInt_Type))}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2410, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_fill_value, __pyx_t_1); __pyx_t_1 = 0;
+2411: if return_index in ('false', 'value', 'val') :
__Pyx_TraceLine(2411,0,__PYX_ERR(0, 2411, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_return_index); __pyx_t_1 = __pyx_v_return_index; __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_false, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2411, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_value, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2411, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_val, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2411, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __pyx_t_5; if (__pyx_t_6) { /* … */ goto __pyx_L3; }
+2412: return_index ='values'
__Pyx_TraceLine(2412,0,__PYX_ERR(0, 2412, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_values); __Pyx_DECREF_SET(__pyx_v_return_index, __pyx_n_u_values);
+2413: elif return_index in ('true', 'index', 'ix') :
__Pyx_TraceLine(2413,0,__PYX_ERR(0, 2413, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_return_index); __pyx_t_1 = __pyx_v_return_index; __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_true, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2413, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L7_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_index, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2413, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L7_bool_binop_done; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_ix, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2413, __pyx_L1_error) __pyx_t_6 = __pyx_t_5; __pyx_L7_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_6; if (__pyx_t_5) { /* … */ goto __pyx_L3; }
+2414: return_index = 'index'
__Pyx_TraceLine(2414,0,__PYX_ERR(0, 2414, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_index); __Pyx_DECREF_SET(__pyx_v_return_index, __pyx_n_u_index);
2415: else :
+2416: return_index = 'mask'
__Pyx_TraceLine(2416,0,__PYX_ERR(0, 2416, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_n_u_mask); __Pyx_DECREF_SET(__pyx_v_return_index, __pyx_n_u_mask); } __pyx_L3:;
2417:
+2418: ref = refarr.copy() ; mask = np.isin(ref, arr)
__Pyx_TraceLine(2418,0,__PYX_ERR(0, 2418, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_refarr, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_ref = __pyx_t_1; __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_ref, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_mask = __pyx_t_1; __pyx_t_1 = 0;
+2419: miss_values = ref [~np.isin(ref, arr)]
__Pyx_TraceLine(2419,0,__PYX_ERR(0, 2419, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_ref, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyNumber_Invert(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_ref, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_miss_values = __pyx_t_1; __pyx_t_1 = 0;
+2420: miss_val_or_ix = (ref [:, None] == miss_values).argmax(axis=0
__pyx_slice__130 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__130)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); /* … */ __Pyx_TraceLine(2420,0,__PYX_ERR(0, 2420, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_ref, __pyx_tuple__131); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_miss_values, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_argmax); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 2420, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } else { __pyx_tuple__131 = PyTuple_Pack(2, __pyx_slice__130, Py_None); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 2420, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__131); __Pyx_GIVEREF(__pyx_tuple__131);
+2421: ) if return_index =='index' else ref [~np.isin(ref, arr)]
__Pyx_TraceLine(2421,0,__PYX_ERR(0, 2421, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_return_index, __pyx_n_u_index, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2421, __pyx_L1_error) if (__pyx_t_5) { /* … */ __Pyx_TraceLine(2421,0,__PYX_ERR(0, 2421, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_ref, __pyx_v_arr}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyNumber_Invert(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_ref, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; } __pyx_v_miss_val_or_ix = __pyx_t_1; __pyx_t_1 = 0;
2422:
+2423: miss_val_or_ix = mask if return_index =='mask' else miss_val_or_ix
__Pyx_TraceLine(2423,0,__PYX_ERR(0, 2423, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_return_index, __pyx_n_u_mask, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2423, __pyx_L1_error) if (__pyx_t_5) { __Pyx_INCREF(__pyx_v_mask); __pyx_t_1 = __pyx_v_mask; } else { __Pyx_INCREF(__pyx_v_miss_val_or_ix); __pyx_t_1 = __pyx_v_miss_val_or_ix; } __Pyx_DECREF_SET(__pyx_v_miss_val_or_ix, __pyx_t_1); __pyx_t_1 = 0;
2424: # if return_missing_values:
+2425: ref [~np.isin(ref, arr)] = fill_value
__Pyx_TraceLine(2425,0,__PYX_ERR(0, 2425, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_v_ref, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyNumber_Invert(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2425, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely((PyObject_SetItem(__pyx_v_ref, __pyx_t_3, __pyx_v_fill_value) < 0))) __PYX_ERR(0, 2425, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2426: #arr= np.hstack ((arr , np.repeat(fill_value, 0 if m <=0 else m )))
2427: #refarr[refarr ==arr] if return_index else arr
+2428: return ref , miss_val_or_ix
__Pyx_TraceLine(2428,0,__PYX_ERR(0, 2428, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_ref); __Pyx_GIVEREF(__pyx_v_ref); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ref)) __PYX_ERR(0, 2428, __pyx_L1_error); __Pyx_INCREF(__pyx_v_miss_val_or_ix); __Pyx_GIVEREF(__pyx_v_miss_val_or_ix); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_miss_val_or_ix)) __PYX_ERR(0, 2428, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
2429:
+2430: def make_arr_consistent (
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_316__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 2430, 0, __PYX_ERR(0, 2430, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(2431,0,__PYX_ERR(0, 2431, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2430, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_fill_value);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_fill_value);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self)->__pyx_arg_fill_value)) __PYX_ERR(0, 2430, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_False))) __PYX_ERR(0, 2430, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_n_u_naive));
__Pyx_GIVEREF(((PyObject*)__pyx_n_u_naive));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject*)__pyx_n_u_naive))) __PYX_ERR(0, 2430, __pyx_L1_error);
/* … */
__Pyx_TraceLine(2430,0,__PYX_ERR(0, 2430, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2430, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 2430, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 2430, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_89make_arr_consistent(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_88make_arr_consistent, "\n Make `arr` to be consistent with the reference array `refarr`. Fill the \n missing value with param `fill_value`. \n \n Note that it does care of the position of the value in the array. Use \n Numpy digitize to compute the bins. The array caveat here is the bins \n must be monotonically decreasing or increasing.\n \n If the values in `arr` are present in `refarr`, the position of `arr` \n in new consistent array should be located decreasing or increasing order. \n \n Parameters \n ------------\n arr: array-like 1d, \n Array to extended with fill value. It should be shorter than the \n `refarr`.\n \n refarr: array-like- the reference array. It should have a greater \n length than the array `arr`. \n fill_value: float, \n Value to fill the `arr` to match the length of the `refarr`. \n return_index: bool or str, default=True \n index of the position of the elements in `refarr`.\n Default is ``False``. If ``mask`` should return the \n mask of existing element in reference array\n method: str, default=\"naive\"\n Is the method used to find the right position of items in `arr`\n based on the reference array. \n - ``naive``, considers the length of ``arr`` must fit the number of \n items that should be visible in the consistent array. This method \n erases the remaining bins values out of length of `arr`. \n - ``strict` did the same but rather than considering the length, \n it considers the maximum values in the `arr`. It assumes that `arr`\n is sorted in ascending order. This methods is usefull for plotting \n a specific stations since the station loactions are sorted in \n ascending order. \n \n Returns \n ---------\n non_zero_index , mask or t \n index: indices of the position of `arr` items in ``refarr``. \n mask: bool of the posit""ion `arr` items in ``refarr``\n t: new consistent array with the same length as ``refarr``\n \n Examples \n ----------\n >>> import numpy as np \n >>> from gofast.tools.coreutils import make_arr_consistent\n >>> refarr = np.arange (12) \n >>> arr = np.arange (7, 10) \n >>> make_arr_consistent (refarr, arr ) \n Out[84]: array([nan, nan, nan, nan, nan, nan, nan, 7., 8., 9., nan, nan])\n >>> make_arr_consistent (refarr, arr , return_index =True )\n Out[104]: array([7, 8, 9], dtype=int64)\n >>> make_arr_consistent (refarr, arr , return_index =\"mask\" )\n Out[105]: \n array([False, False, False, False, False, False, False, True, True,\n True, False, False])\n >>> a = np.arange ( 12 ); b = np.linspace (7, 10 , 7) \n >>> make_arr_consistent (a, b ) \n Out[112]: array([nan, nan, nan, nan, nan, nan, nan, 7., 8., 9., 10., 11.])\n >>> make_arr_consistent (a, b ,method='strict') \n Out[114]: array([nan, nan, nan, nan, nan, nan, nan, 7., 8., 9., 10., nan])\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_89make_arr_consistent = {"make_arr_consistent", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_89make_arr_consistent, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_88make_arr_consistent};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_89make_arr_consistent(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_refarr = 0;
PyObject *__pyx_v_arr = 0;
PyObject *__pyx_v_fill_value = 0;
PyObject *__pyx_v_return_index = 0;
PyObject *__pyx_v_method = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("make_arr_consistent (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_refarr,&__pyx_n_s_arr,&__pyx_n_s_fill_value,&__pyx_n_s_return_index,&__pyx_n_s_method,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults5 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_self);
values[2] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_fill_value);
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_naive)));
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_refarr)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2430, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2430, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("make_arr_consistent", 0, 2, 5, 1); __PYX_ERR(0, 2430, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fill_value);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2430, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_index);
if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2430, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_method);
if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2430, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "make_arr_consistent") < 0)) __PYX_ERR(0, 2430, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_refarr = values[0];
__pyx_v_arr = values[1];
__pyx_v_fill_value = values[2];
__pyx_v_return_index = values[3];
__pyx_v_method = values[4];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("make_arr_consistent", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 2430, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.make_arr_consistent", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_88make_arr_consistent(__pyx_self, __pyx_v_refarr, __pyx_v_arr, __pyx_v_fill_value, __pyx_v_return_index, __pyx_v_method);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_88make_arr_consistent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_refarr, PyObject *__pyx_v_arr, PyObject *__pyx_v_fill_value, PyObject *__pyx_v_return_index, PyObject *__pyx_v_method) {
PyObject *__pyx_v_t = NULL;
PyObject *__pyx_v_temp_arr = NULL;
PyObject *__pyx_v_non_zero_index = NULL;
PyObject *__pyx_v_index = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__132)
__Pyx_TraceCall("make_arr_consistent", __pyx_f[0], 2430, 0, __PYX_ERR(0, 2430, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_refarr);
__Pyx_INCREF(__pyx_v_arr);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_XDECREF(__pyx_t_14);
__Pyx_AddTraceback("gofast.tools.coreutils.make_arr_consistent", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_t);
__Pyx_XDECREF(__pyx_v_temp_arr);
__Pyx_XDECREF(__pyx_v_non_zero_index);
__Pyx_XDECREF(__pyx_v_index);
__Pyx_XDECREF(__pyx_v_refarr);
__Pyx_XDECREF(__pyx_v_arr);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_92generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
/* … */
__pyx_tuple__409 = PyTuple_Pack(9, __pyx_n_s_refarr, __pyx_n_s_arr, __pyx_n_s_fill_value, __pyx_n_s_return_index, __pyx_n_s_method, __pyx_n_s_t, __pyx_n_s_temp_arr, __pyx_n_s_non_zero_index, __pyx_n_s_index); if (unlikely(!__pyx_tuple__409)) __PYX_ERR(0, 2430, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__409);
__Pyx_GIVEREF(__pyx_tuple__409);
/* … */
__Pyx_TraceLine(2430,0,__PYX_ERR(0, 2430, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_89make_arr_consistent, 0, __pyx_n_s_make_arr_consistent, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__132)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2430, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults5), 1)) __PYX_ERR(0, 2430, __pyx_L1_error)
__pyx_codeobj__132 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__409, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_make_arr_consistent, 2430, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__132)) __PYX_ERR(0, 2430, __pyx_L1_error)
+2431: refarr, arr, fill_value = np.nan, return_index = False,
__Pyx_TraceLine(2431,0,__PYX_ERR(0, 2431, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_nan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2431, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults5, __pyx_t_2)->__pyx_arg_fill_value = __pyx_t_4; __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_6gofast_5tools_9coreutils_316__defaults__); if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_arr_consistent, __pyx_t_2) < 0) __PYX_ERR(0, 2430, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2432: method='naive'):
2433: """
2434: Make `arr` to be consistent with the reference array `refarr`. Fill the
2435: missing value with param `fill_value`.
2436:
2437: Note that it does care of the position of the value in the array. Use
2438: Numpy digitize to compute the bins. The array caveat here is the bins
2439: must be monotonically decreasing or increasing.
2440:
2441: If the values in `arr` are present in `refarr`, the position of `arr`
2442: in new consistent array should be located decreasing or increasing order.
2443:
2444: Parameters
2445: ------------
2446: arr: array-like 1d,
2447: Array to extended with fill value. It should be shorter than the
2448: `refarr`.
2449:
2450: refarr: array-like- the reference array. It should have a greater
2451: length than the array `arr`.
2452: fill_value: float,
2453: Value to fill the `arr` to match the length of the `refarr`.
2454: return_index: bool or str, default=True
2455: index of the position of the elements in `refarr`.
2456: Default is ``False``. If ``mask`` should return the
2457: mask of existing element in reference array
2458: method: str, default="naive"
2459: Is the method used to find the right position of items in `arr`
2460: based on the reference array.
2461: - ``naive``, considers the length of ``arr`` must fit the number of
2462: items that should be visible in the consistent array. This method
2463: erases the remaining bins values out of length of `arr`.
2464: - ``strict` did the same but rather than considering the length,
2465: it considers the maximum values in the `arr`. It assumes that `arr`
2466: is sorted in ascending order. This methods is usefull for plotting
2467: a specific stations since the station loactions are sorted in
2468: ascending order.
2469:
2470: Returns
2471: ---------
2472: non_zero_index , mask or t
2473: index: indices of the position of `arr` items in ``refarr``.
2474: mask: bool of the position `arr` items in ``refarr``
2475: t: new consistent array with the same length as ``refarr``
2476:
2477: Examples
2478: ----------
2479: >>> import numpy as np
2480: >>> from gofast.tools.coreutils import make_arr_consistent
2481: >>> refarr = np.arange (12)
2482: >>> arr = np.arange (7, 10)
2483: >>> make_arr_consistent (refarr, arr )
2484: Out[84]: array([nan, nan, nan, nan, nan, nan, nan, 7., 8., 9., nan, nan])
2485: >>> make_arr_consistent (refarr, arr , return_index =True )
2486: Out[104]: array([7, 8, 9], dtype=int64)
2487: >>> make_arr_consistent (refarr, arr , return_index ="mask" )
2488: Out[105]:
2489: array([False, False, False, False, False, False, False, True, True,
2490: True, False, False])
2491: >>> a = np.arange ( 12 ); b = np.linspace (7, 10 , 7)
2492: >>> make_arr_consistent (a, b )
2493: Out[112]: array([nan, nan, nan, nan, nan, nan, nan, 7., 8., 9., 10., 11.])
2494: >>> make_arr_consistent (a, b ,method='strict')
2495: Out[114]: array([nan, nan, nan, nan, nan, nan, nan, 7., 8., 9., 10., nan])
2496: """
+2497: try :
__Pyx_TraceLine(2497,0,__PYX_ERR(0, 2497, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); }
+2498: refarr = reshape( refarr).shape[1]
__Pyx_TraceLine(2498,0,__PYX_ERR(0, 2498, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_reshape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2498, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_refarr}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2498, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2498, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2498, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_refarr, __pyx_t_4); __pyx_t_4 = 0;
+2499: arr= reshape( arr).shape[1]
__Pyx_TraceLine(2499,0,__PYX_ERR(0, 2499, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_reshape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2499, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_arr}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2499, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2499, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_5, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2499, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_4); __pyx_t_4 = 0;
+2500: except :pass
__Pyx_TraceLine(2500,0,__PYX_ERR(0, 2500, __pyx_L5_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; }
+2501: else: raise TypeError ("Expects one-dimensional arrays for both arrays.")
__Pyx_TraceLine(2501,0,__PYX_ERR(0, 2501, __pyx_L5_except_error)) /*else:*/ { __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__133, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2501, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 2501, __pyx_L5_except_error) } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple__133 = PyTuple_Pack(1, __pyx_kp_u_Expects_one_dimensional_arrays_f); if (unlikely(!__pyx_tuple__133)) __PYX_ERR(0, 2501, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__133); __Pyx_GIVEREF(__pyx_tuple__133);
2502:
+2503: t = np.full_like( refarr, fill_value = np.nan, dtype =float )
__Pyx_TraceLine(2503,0,__PYX_ERR(0, 2503, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_full_like); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_refarr); __Pyx_GIVEREF(__pyx_v_refarr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_refarr)) __PYX_ERR(0, 2503, __pyx_L1_error); __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_nan); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_fill_value, __pyx_t_9) < 0) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 2503, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_t = __pyx_t_9; __pyx_t_9 = 0;
+2504: temp_arr = np.digitize( refarr, arr)
__Pyx_TraceLine(2504,0,__PYX_ERR(0, 2504, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_digitize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_refarr, __pyx_v_arr}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_temp_arr = __pyx_t_9; __pyx_t_9 = 0;
+2505: non_zero_index = reshape (np.argwhere (temp_arr!=0 ) )
__Pyx_TraceLine(2505,0,__PYX_ERR(0, 2505, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_argwhere); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_NeObjC(__pyx_v_temp_arr, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_5}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_6}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_non_zero_index = __pyx_t_9; __pyx_t_9 = 0;
+2506: t[non_zero_index] = refarr [non_zero_index]
__Pyx_TraceLine(2506,0,__PYX_ERR(0, 2506, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_refarr, __pyx_v_non_zero_index); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2506, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely((PyObject_SetItem(__pyx_v_t, __pyx_v_non_zero_index, __pyx_t_9) < 0))) __PYX_ERR(0, 2506, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2507: # force value to keep only
2508: # value in array
+2509: if method=='strict':
__Pyx_TraceLine(2509,0,__PYX_ERR(0, 2509, __pyx_L1_error)) __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_v_method, __pyx_n_u_strict, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 2509, __pyx_L1_error) if (__pyx_t_11) { /* … */ goto __pyx_L9; }
+2510: index = reshape ( np.argwhere ( (max( arr) - t) < 0 ) )
__Pyx_TraceLine(2510,0,__PYX_ERR(0, 2510, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_argwhere); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_max, __pyx_v_arr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = PyNumber_Subtract(__pyx_t_8, __pyx_v_t); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyObject_RichCompare(__pyx_t_10, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_8}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_6}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2510, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_index = __pyx_t_9; __pyx_t_9 = 0;
+2511: t [index ]= np.nan
__Pyx_TraceLine(2511,0,__PYX_ERR(0, 2511, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_nan); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely((PyObject_SetItem(__pyx_v_t, __pyx_v_index, __pyx_t_4) < 0))) __PYX_ERR(0, 2511, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2512: else:
+2513: if len (t[~np.isnan (t)]) > len(arr):
__Pyx_TraceLine(2513,0,__PYX_ERR(0, 2513, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_t}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyNumber_Invert(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_t, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_12 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2513, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2513, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 > __pyx_t_13); if (__pyx_t_11) { /* … */ } } __pyx_L9:;
+2514: t [ - (len(t[~np.isnan (t)])-len(arr)):]= np.nan
__Pyx_TraceLine(2514,0,__PYX_ERR(0, 2514, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isnan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_t}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = PyNumber_Invert(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_t, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_13 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2514, __pyx_L1_error) if (__Pyx_PyObject_SetSlice(__pyx_v_t, __pyx_t_6, (-(__pyx_t_13 - __pyx_t_12)), 0, NULL, NULL, NULL, 1, 0, 1) < 0) __PYX_ERR(0, 2514, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2515: # update the non_zeros index
+2516: non_zero_index= reshape ( np.argwhere (~np.isnan (t)))
__Pyx_TraceLine(2516,0,__PYX_ERR(0, 2516, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_argwhere); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_isnan); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_t}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __pyx_t_14 = PyNumber_Invert(__pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_14}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_5}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_non_zero_index, __pyx_t_6); __pyx_t_6 = 0;
2517: # now replace all NaN value by filled value
+2518: t [np.isnan(t)] = fill_value
__Pyx_TraceLine(2518,0,__PYX_ERR(0, 2518, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isnan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_t}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_t, __pyx_t_6, __pyx_v_fill_value) < 0))) __PYX_ERR(0, 2518, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2519:
+2520: return refarr == t if return_index =='mask' else (
__Pyx_TraceLine(2520,0,__PYX_ERR(0, 2520, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_v_return_index, __pyx_n_u_mask, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 2520, __pyx_L1_error) if (__pyx_t_11) { __pyx_t_5 = PyObject_RichCompare(__pyx_v_refarr, __pyx_v_t, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2520, __pyx_L1_error) __pyx_t_6 = __pyx_t_5; __pyx_t_5 = 0; } else {
+2521: non_zero_index if return_index else t )
__Pyx_TraceLine(2521,0,__PYX_ERR(0, 2521, __pyx_L1_error)) __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_v_return_index); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 2521, __pyx_L1_error) if (__pyx_t_15) { __Pyx_INCREF(__pyx_v_non_zero_index); __pyx_t_5 = __pyx_v_non_zero_index; } else { __Pyx_INCREF(__pyx_v_t); __pyx_t_5 = __pyx_v_t; } __pyx_t_6 = __pyx_t_5; __pyx_t_5 = 0; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
2522:
+2523: def find_close_position (refarr, arr):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_91find_close_position(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_90find_close_position, " Get the close item from `arr` in the reference array `refarr`. \n \n :param arr: array-like 1d, \n Array to extended with fill value. It should be shorter than the \n `refarr`.\n \n :param refarr: array-like- \n the reference array. It should have a greater length than the\n array `arr`. \n :return: generator of index of the closest position in `refarr`. \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_91find_close_position = {"find_close_position", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_91find_close_position, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_90find_close_position}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_91find_close_position(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_refarr = 0; PyObject *__pyx_v_arr = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("find_close_position (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_refarr,&__pyx_n_s_arr,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_refarr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2523, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2523, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("find_close_position", 1, 2, 2, 1); __PYX_ERR(0, 2523, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "find_close_position") < 0)) __PYX_ERR(0, 2523, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_refarr = values[0]; __pyx_v_arr = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("find_close_position", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 2523, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.find_close_position", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_90find_close_position(__pyx_self, __pyx_v_refarr, __pyx_v_arr); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_90find_close_position(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_refarr, PyObject *__pyx_v_arr) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_9_find_close_position *__pyx_cur_scope; PyObject *__pyx_r = NULL; __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_9_find_close_position *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_9_find_close_position(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_9_find_close_position, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_9_find_close_position *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 2523, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_refarr = __pyx_v_refarr; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_refarr); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_refarr); __pyx_cur_scope->__pyx_v_arr = __pyx_v_arr; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_arr); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_arr); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_92generator2, __pyx_codeobj__134, (PyObject *) __pyx_cur_scope, __pyx_n_s_find_close_position, __pyx_n_s_find_close_position, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 2523, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("gofast.tools.coreutils.find_close_position", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_92generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("find_close_position", 0); __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__134) __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2523, __pyx_L1_error) /* … */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_Generator_Replace_StopIteration(0); __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("find_close_position", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__410 = PyTuple_Pack(4, __pyx_n_s_refarr, __pyx_n_s_arr, __pyx_n_s_item, __pyx_n_s_ix); if (unlikely(!__pyx_tuple__410)) __PYX_ERR(0, 2523, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__410); __Pyx_GIVEREF(__pyx_tuple__410); /* … */ __Pyx_TraceLine(2523,0,__PYX_ERR(0, 2523, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_91find_close_position, 0, __pyx_n_s_find_close_position, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__134)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2523, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_find_close_position, __pyx_t_2) < 0) __PYX_ERR(0, 2523, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__134 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__410, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_find_close_position, 2523, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__134)) __PYX_ERR(0, 2523, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_9_find_close_position { PyObject_HEAD PyObject *__pyx_v_arr; PyObject *__pyx_v_item; PyObject *__pyx_v_ix; PyObject *__pyx_v_refarr; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; PyObject *(*__pyx_t_2)(PyObject *); };
2524: """ Get the close item from `arr` in the reference array `refarr`.
2525:
2526: :param arr: array-like 1d,
2527: Array to extended with fill value. It should be shorter than the
2528: `refarr`.
2529:
2530: :param refarr: array-like-
2531: the reference array. It should have a greater length than the
2532: array `arr`.
2533: :return: generator of index of the closest position in `refarr`.
2534: """
+2535: for item in arr :
__Pyx_TraceLine(2535,0,__PYX_ERR(0, 2535, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_arr)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_arr)) { __pyx_t_1 = __pyx_cur_scope->__pyx_v_arr; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_arr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2535, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2535, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 2535, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2535, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 2535, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2535, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2535, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_item); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_item, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(2535,0,__PYX_ERR(0, 2535, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
+2536: ix = np.argmin (np.abs (refarr - item))
__Pyx_TraceLine(2536,0,__PYX_ERR(0, 2536, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_argmin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_abs); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_refarr, __pyx_cur_scope->__pyx_v_item); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_7}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_5}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ix); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ix, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0;
+2537: yield ix
__Pyx_TraceLine(2537,0,__PYX_ERR(0, 2537, __pyx_L1_error)) __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ix); __pyx_r = __pyx_cur_scope->__pyx_v_ix; __Pyx_XGIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_1); __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2537, __pyx_L1_error)
2538:
2539:
+2540: def fit_ll(ediObjs, by ='index', method ='strict', distance='cartesian' ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_94fit_ll(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_93fit_ll, " Fit EDI by location and reorganize EDI according to the site \n longitude and latitude coordinates. \n \n EDIs data are mostly reading in an alphabetically order, so the reoganization \n\n according to the location(longitude and latitude) is usefull for distance \n betwen site computing with a right position at each site. \n \n :param ediObjs: list of EDI object, composed of a collection of \n gofast.edi.Edi or pycsamt.core.edi.Edi or mtpy.core.edi objects \n :type ediObjs: gofast.edi.Edi_Collection \n \n :param by: ['name'|'ll'|'distance'|'index'|'name'|'dataid'] \n The kind to sorting EDI files. Default uses the position number \n included in the EDI-files name.\n :type by: str \n \n :param method: ['strict|'naive']. Kind of method to sort the \n EDI file from longitude, latitude. Default is ``strict``. \n :type method: str \n \n :param distance: ['cartesian'|'harvesine']. Use the distance between \n coordinates points to sort EDI files. Default is ``cartesian`` distance.\n :type distance: str \n \n :returns: array splitted into ediObjs and Edifiles basenames \n :rtyple: tuple \n \n :Example: \n >>> import numpy as np \n >>> from gofast.methods.em import EM\n >>> from gofast.tools.coreutils import fit_ll\n >>> edipath ='data/edi_ss' \n >>> cediObjs = EM().fit (edipath) \n >>> ediObjs = np.random.permutation(cediObjs.ediObjs) # shuffle the \n ... # the collection of ediObjs \n >>> ediObjs, ediObjbname = fit_by_ll(ediObjs) \n ...\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_94fit_ll = {"fit_ll", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_94fit_ll, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_93fit_ll}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_94fit_ll(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_ediObjs = 0; PyObject *__pyx_v_by = 0; PyObject *__pyx_v_method = 0; PyObject *__pyx_v_distance = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fit_ll (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ediObjs,&__pyx_n_s_by,&__pyx_n_s_method,&__pyx_n_s_distance,0}; PyObject* values[4] = {0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_index))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_strict))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_cartesian))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ediObjs)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2540, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_by); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2540, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_method); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2540, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_distance); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2540, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "fit_ll") < 0)) __PYX_ERR(0, 2540, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ediObjs = values[0]; __pyx_v_by = values[1]; __pyx_v_method = values[2]; __pyx_v_distance = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fit_ll", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 2540, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.fit_ll", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_93fit_ll(__pyx_self, __pyx_v_ediObjs, __pyx_v_by, __pyx_v_method, __pyx_v_distance); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_93fit_ll(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ediObjs, PyObject *__pyx_v_by, PyObject *__pyx_v_method, PyObject *__pyx_v_distance) { PyObject *__pyx_v_objnames = NULL; PyObject *__pyx_v_lataddlon = NULL; PyObject *__pyx_v_sort_ix = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__135) __Pyx_TraceCall("fit_ll", __pyx_f[0], 2540, 0, __PYX_ERR(0, 2540, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_method); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.fit_ll", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_objnames); __Pyx_XDECREF(__pyx_v_lataddlon); __Pyx_XDECREF(__pyx_v_sort_ix); __Pyx_XDECREF(__pyx_v_method); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__411 = PyTuple_Pack(7, __pyx_n_s_ediObjs, __pyx_n_s_by, __pyx_n_s_method, __pyx_n_s_distance, __pyx_n_s_objnames, __pyx_n_s_lataddlon, __pyx_n_s_sort_ix); if (unlikely(!__pyx_tuple__411)) __PYX_ERR(0, 2540, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__411); __Pyx_GIVEREF(__pyx_tuple__411); __pyx_codeobj__135 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__411, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fit_ll_2, 2540, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__135)) __PYX_ERR(0, 2540, __pyx_L1_error) /* … */ __Pyx_TraceLine(2540,0,__PYX_ERR(0, 2540, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_94fit_ll, 0, __pyx_n_s_fit_ll_2, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__135)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2540, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__412); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fit_ll_2, __pyx_t_2) < 0) __PYX_ERR(0, 2540, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__412 = PyTuple_Pack(3, ((PyObject*)__pyx_n_u_index), ((PyObject*)__pyx_n_u_strict), ((PyObject*)__pyx_n_u_cartesian)); if (unlikely(!__pyx_tuple__412)) __PYX_ERR(0, 2540, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__412); __Pyx_GIVEREF(__pyx_tuple__412);
2541: """ Fit EDI by location and reorganize EDI according to the site
2542: longitude and latitude coordinates.
2543:
2544: EDIs data are mostly reading in an alphabetically order, so the reoganization
2545:
2546: according to the location(longitude and latitude) is usefull for distance
2547: betwen site computing with a right position at each site.
2548:
2549: :param ediObjs: list of EDI object, composed of a collection of
2550: gofast.edi.Edi or pycsamt.core.edi.Edi or mtpy.core.edi objects
2551: :type ediObjs: gofast.edi.Edi_Collection
2552:
2553: :param by: ['name'|'ll'|'distance'|'index'|'name'|'dataid']
2554: The kind to sorting EDI files. Default uses the position number
2555: included in the EDI-files name.
2556: :type by: str
2557:
2558: :param method: ['strict|'naive']. Kind of method to sort the
2559: EDI file from longitude, latitude. Default is ``strict``.
2560: :type method: str
2561:
2562: :param distance: ['cartesian'|'harvesine']. Use the distance between
2563: coordinates points to sort EDI files. Default is ``cartesian`` distance.
2564: :type distance: str
2565:
2566: :returns: array splitted into ediObjs and Edifiles basenames
2567: :rtyple: tuple
2568:
2569: :Example:
2570: >>> import numpy as np
2571: >>> from gofast.methods.em import EM
2572: >>> from gofast.tools.coreutils import fit_ll
2573: >>> edipath ='data/edi_ss'
2574: >>> cediObjs = EM().fit (edipath)
2575: >>> ediObjs = np.random.permutation(cediObjs.ediObjs) # shuffle the
2576: ... # the collection of ediObjs
2577: >>> ediObjs, ediObjbname = fit_by_ll(ediObjs)
2578: ...
2579:
2580: """
+2581: method= 'strict' if str(method).lower() =='strict' else "naive"
__Pyx_TraceLine(2581,0,__PYX_ERR(0, 2581, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_method); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_strict, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2581, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { __Pyx_INCREF(__pyx_n_u_strict); __pyx_t_1 = __pyx_n_u_strict; } else { __Pyx_INCREF(__pyx_n_u_naive); __pyx_t_1 = __pyx_n_u_naive; } __Pyx_DECREF_SET(__pyx_v_method, __pyx_t_1); __pyx_t_1 = 0;
+2582: if method=='strict':
__Pyx_TraceLine(2582,0,__PYX_ERR(0, 2582, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_method, __pyx_n_u_strict, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2582, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+2583: return _fit_ll(ediObjs, by = by, distance = distance )
__Pyx_TraceLine(2583,0,__PYX_ERR(0, 2583, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fit_ll); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_ediObjs); __Pyx_GIVEREF(__pyx_v_ediObjs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_ediObjs)) __PYX_ERR(0, 2583, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_by, __pyx_v_by) < 0) __PYX_ERR(0, 2583, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_distance, __pyx_v_distance) < 0) __PYX_ERR(0, 2583, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
2584:
2585: #get the ediObjs+ names in ndarray(len(ediObjs), 2)
+2586: objnames = np.c_[ediObjs, np.array(
__Pyx_TraceLine(2586,0,__PYX_ERR(0, 2586, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_c); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(2586,0,__PYX_ERR(0, 2586, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_ediObjs); __Pyx_GIVEREF(__pyx_v_ediObjs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ediObjs)) __PYX_ERR(0, 2586, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3)) __PYX_ERR(0, 2586, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_objnames = __pyx_t_3; __pyx_t_3 = 0;
+2587: list(map(lambda obj: os.path.basename(obj.edifile), ediObjs)))]
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_6fit_ll_lambda4(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_6fit_ll_lambda4 = {"lambda4", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_6fit_ll_lambda4, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_6fit_ll_lambda4(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_obj = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda4 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2587, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda4") < 0)) __PYX_ERR(0, 2587, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_obj = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda4", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2587, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.fit_ll.lambda4", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda4(__pyx_self, __pyx_v_obj);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda4(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda4", __pyx_f[0], 2587, 0, __PYX_ERR(0, 2587, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_basename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_edifile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.fit_ll.lambda4", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2587,0,__PYX_ERR(0, 2587, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_6fit_ll_lambda4, 0, __pyx_n_s_fit_ll_locals_lambda, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_2);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_ediObjs);
__Pyx_GIVEREF(__pyx_v_ediObjs);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ediObjs)) __PYX_ERR(0, 2587, __pyx_L1_error);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2587, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_1))) {
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
if (likely(__pyx_t_2)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
__Pyx_INCREF(__pyx_t_2);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_1, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_7};
__pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2586, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
+2588: lataddlon = np.array (list(map(lambda obj: obj.lat + obj.lon , ediObjs)))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_6fit_ll_1lambda5(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_6fit_ll_1lambda5 = {"lambda5", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_6fit_ll_1lambda5, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_6fit_ll_1lambda5(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_obj = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda5 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2588, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda5") < 0)) __PYX_ERR(0, 2588, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_obj = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda5", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2588, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.fit_ll.lambda5", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda5(__pyx_self, __pyx_v_obj);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda5(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda5", __pyx_f[0], 2588, 0, __PYX_ERR(0, 2588, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_lat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_lon); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("gofast.tools.coreutils.fit_ll.lambda5", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2588,0,__PYX_ERR(0, 2588, __pyx_L1_error))
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_6fit_ll_1lambda5, 0, __pyx_n_s_fit_ll_locals_lambda, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_ediObjs);
__Pyx_GIVEREF(__pyx_v_ediObjs);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ediObjs)) __PYX_ERR(0, 2588, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_1)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_1);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_7};
__pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2588, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
}
__pyx_v_lataddlon = __pyx_t_3;
__pyx_t_3 = 0;
+2589: if len(np.unique ( lataddlon)) < len(ediObjs)//2:
__Pyx_TraceLine(2589,0,__PYX_ERR(0, 2589, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_unique); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_lataddlon}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2589, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_8 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2589, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = PyObject_Length(__pyx_v_ediObjs); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2589, __pyx_L1_error) __pyx_t_6 = (__pyx_t_8 < __Pyx_div_Py_ssize_t(__pyx_t_9, 2)); if (__pyx_t_6) { goto __pyx_L4; }
2590: # then ignore reorganization and used the
2591: # station names.
2592: pass
2593: else:
+2594: sort_ix = np.argsort(lataddlon)
__Pyx_TraceLine(2594,0,__PYX_ERR(0, 2594, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_argsort); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_lataddlon}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2594, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_sort_ix = __pyx_t_3; __pyx_t_3 = 0;
+2595: objnames = objnames[sort_ix ]
__Pyx_TraceLine(2595,0,__PYX_ERR(0, 2595, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_objnames, __pyx_v_sort_ix); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2595, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_objnames, __pyx_t_3); __pyx_t_3 = 0; } __pyx_L4:;
2596:
2597: #ediObjs , objbnames = np.hsplit(objnames, 2)
+2598: return objnames[:, 0], objnames[:, -1]
__Pyx_TraceLine(2598,0,__PYX_ERR(0, 2598, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_objnames, __pyx_tuple__136); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __pyx_tuple__136 = PyTuple_Pack(2, __pyx_slice__130, __pyx_int_0); if (unlikely(!__pyx_tuple__136)) __PYX_ERR(0, 2598, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__136); __Pyx_GIVEREF(__pyx_tuple__136); __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_objnames, __pyx_tuple__137); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_3)) __PYX_ERR(0, 2598, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4)) __PYX_ERR(0, 2598, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_4 = 0; __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L0; __pyx_tuple__137 = PyTuple_Pack(2, __pyx_slice__130, __pyx_int_neg_1); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 2598, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__137); __Pyx_GIVEREF(__pyx_tuple__137);
2599:
+2600: def _fit_ll(ediObjs, distance='cartes', by = 'index'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_96_fit_ll(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_95_fit_ll, " Fit ediObjs using the `strict method`. \n \n An isolated part of :func:`gofast.tools.coreutils.fit_by_ll`. \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_96_fit_ll = {"_fit_ll", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_96_fit_ll, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_95_fit_ll}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_96_fit_ll(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_ediObjs = 0; PyObject *__pyx_v_distance = 0; PyObject *__pyx_v_by = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_fit_ll (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ediObjs,&__pyx_n_s_distance,&__pyx_n_s_by,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_cartes))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_index))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ediObjs)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2600, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_distance); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2600, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_by); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2600, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_fit_ll") < 0)) __PYX_ERR(0, 2600, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ediObjs = values[0]; __pyx_v_distance = values[1]; __pyx_v_by = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_fit_ll", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 2600, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._fit_ll", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_95_fit_ll(__pyx_self, __pyx_v_ediObjs, __pyx_v_distance, __pyx_v_by); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_95_fit_ll(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ediObjs, PyObject *__pyx_v_distance, PyObject *__pyx_v_by) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll *__pyx_cur_scope; PyObject *__pyx_v_obj_init = NULL; double __pyx_v_ref_lat; double __pyx_v_ref_lon; PyObject *__pyx_v_stations = NULL; PyObject *__pyx_v_sorted_stations = NULL; PyObject *__pyx_v_objnames = NULL; PyObject *__pyx_9genexpr32__pyx_v_ii = NULL; PyObject *__pyx_9genexpr32__pyx_v_obj = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__138) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 2600, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("_fit_ll", __pyx_f[0], 2600, 0, __PYX_ERR(0, 2600, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_by = __pyx_v_by; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_by); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_by); __Pyx_INCREF(__pyx_v_ediObjs); __Pyx_INCREF(__pyx_v_distance); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("gofast.tools.coreutils._fit_ll", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_obj_init); __Pyx_XDECREF(__pyx_v_stations); __Pyx_XDECREF(__pyx_v_sorted_stations); __Pyx_XDECREF(__pyx_v_objnames); __Pyx_XDECREF(__pyx_9genexpr32__pyx_v_ii); __Pyx_XDECREF(__pyx_9genexpr32__pyx_v_obj); __Pyx_XDECREF(__pyx_v_ediObjs); __Pyx_XDECREF(__pyx_v_distance); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__413 = PyTuple_Pack(12, __pyx_n_s_ediObjs, __pyx_n_s_distance, __pyx_n_s_by, __pyx_n_s_obj_init, __pyx_n_s_ref_lat, __pyx_n_s_ref_lon, __pyx_n_s_stations, __pyx_n_s_ll, __pyx_n_s_sorted_stations, __pyx_n_s_objnames, __pyx_n_s_ii, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__413)) __PYX_ERR(0, 2600, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__413); __Pyx_GIVEREF(__pyx_tuple__413); __pyx_codeobj__138 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__413, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fit_ll, 2600, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__138)) __PYX_ERR(0, 2600, __pyx_L1_error) /* … */ __Pyx_TraceLine(2600,0,__PYX_ERR(0, 2600, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_96_fit_ll, 0, __pyx_n_s_fit_ll, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__138)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__414); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fit_ll, __pyx_t_2) < 0) __PYX_ERR(0, 2600, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__414 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u_cartes), ((PyObject*)__pyx_n_u_index)); if (unlikely(!__pyx_tuple__414)) __PYX_ERR(0, 2600, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__414); __Pyx_GIVEREF(__pyx_tuple__414); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll { PyObject_HEAD PyObject *__pyx_v_by; PyObject *__pyx_v_ll; };
2601: """ Fit ediObjs using the `strict method`.
2602:
2603: An isolated part of :func:`gofast.tools.coreutils.fit_by_ll`.
2604: """
2605: # get one obj randomnly and compute distance
+2606: obj_init = ediObjs[0]
__Pyx_TraceLine(2606,0,__PYX_ERR(0, 2606, __pyx_L1_error)) __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ediObjs, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_obj_init = __pyx_t_1; __pyx_t_1 = 0;
+2607: ref_lat = 34.0522 # Latitude of Los Angeles
__Pyx_TraceLine(2607,0,__PYX_ERR(0, 2607, __pyx_L1_error)) __pyx_v_ref_lat = 34.0522;
+2608: ref_lon = -118.2437 # Longitude of Los Angeles
__Pyx_TraceLine(2608,0,__PYX_ERR(0, 2608, __pyx_L1_error)) __pyx_v_ref_lon = -118.2437;
2609:
+2610: if str(distance).find ('harves')>=0:
__Pyx_TraceLine(2610,0,__PYX_ERR(0, 2610, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_distance); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_harves}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2610, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2610, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2610, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { /* … */ goto __pyx_L3; }
+2611: distance='harves'
__Pyx_TraceLine(2611,0,__PYX_ERR(0, 2611, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_harves); __Pyx_DECREF_SET(__pyx_v_distance, __pyx_n_u_harves);
+2612: else: distance='cartes'
__Pyx_TraceLine(2612,0,__PYX_ERR(0, 2612, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_n_u_cartes); __Pyx_DECREF_SET(__pyx_v_distance, __pyx_n_u_cartes); } __pyx_L3:;
2613:
2614: # create stations list.
+2615: stations = [
__Pyx_TraceLine(2615,0,__PYX_ERR(0, 2615, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2615, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0;
+2616: {"name": os.path.basename(obj.edifile),
__Pyx_TraceLine(2616,0,__PYX_ERR(0, 2616, __pyx_L6_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_os); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_basename); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_edifile); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_11}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_name_2, __pyx_t_9) < 0) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2617: "longitude": obj.lon,
__Pyx_TraceLine(2617,0,__PYX_ERR(0, 2617, __pyx_L6_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_lon); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2617, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_longitude, __pyx_t_9) < 0) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2618: "latitude": obj.lat,
__Pyx_TraceLine(2618,0,__PYX_ERR(0, 2618, __pyx_L6_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_lat); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2618, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_latitude, __pyx_t_9) < 0) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2619: "obj": obj,
__Pyx_TraceLine(2619,0,__PYX_ERR(0, 2619, __pyx_L6_error)) if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_obj, __pyx_9genexpr32__pyx_v_obj) < 0) __PYX_ERR(0, 2616, __pyx_L6_error)
+2620: "dataid": obj.dataid,
__Pyx_TraceLine(2620,0,__PYX_ERR(0, 2620, __pyx_L6_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_dataid); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2620, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_dataid, __pyx_t_9) < 0) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2621: # compute distance using cartesian or harversine
+2622: "distance": _compute_haversine_d (
__Pyx_TraceLine(2622,0,__PYX_ERR(0, 2622, __pyx_L6_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_compute_haversine_d); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2622, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11);
+2623: ref_lat, ref_lon, obj.lat, obj.lon
__Pyx_TraceLine(2623,0,__PYX_ERR(0, 2623, __pyx_L6_error)) __pyx_t_12 = PyFloat_FromDouble(__pyx_v_ref_lat); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2623, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyFloat_FromDouble(__pyx_v_ref_lon); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2623, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_lat); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2623, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_lon); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2623, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_16, __pyx_t_12, __pyx_t_13, __pyx_t_14, __pyx_t_15}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 4+__pyx_t_4); __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2622, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_9 = __pyx_t_10; __pyx_t_10 = 0; } else {
+2624: ) if distance =='harves' else np.sqrt (
__Pyx_TraceLine(2624,0,__PYX_ERR(0, 2624, __pyx_L6_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_distance, __pyx_n_u_harves, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2624, __pyx_L6_error) if (__pyx_t_5) { /* … */ __Pyx_TraceLine(2624,0,__PYX_ERR(0, 2624, __pyx_L6_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2624, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2624, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+2625: ( obj_init.lon -obj.lon)**2 + (obj_init.lat -obj.lat)**2),
__Pyx_TraceLine(2625,0,__PYX_ERR(0, 2625, __pyx_L6_error)) __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj_init, __pyx_n_s_lon); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_lon); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = PyNumber_Subtract(__pyx_t_11, __pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = PyNumber_Power(__pyx_t_13, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj_init, __pyx_n_s_lat); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_lat); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = PyNumber_Subtract(__pyx_t_13, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Power(__pyx_t_12, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyNumber_Add(__pyx_t_14, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2625, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_15))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_t_12}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2624, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_9 = __pyx_t_10; __pyx_t_10 = 0; } if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_distance, __pyx_t_9) < 0) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
2626: # check wether there is a position number in the data.
+2627: "index": re.search ('\d+', str(os.path.basename(obj.edifile)),
__Pyx_TraceLine(2627,0,__PYX_ERR(0, 2627, __pyx_L6_error)) __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_re); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_search); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_os); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_path); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_basename); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_edifile); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_14}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = __Pyx_PyObject_Str(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_kp_u_d_2); __Pyx_GIVEREF(__pyx_kp_u_d_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_kp_u_d_2)) __PYX_ERR(0, 2627, __pyx_L6_error); __Pyx_GIVEREF(__pyx_t_11); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_11)) __PYX_ERR(0, 2627, __pyx_L6_error); __pyx_t_11 = 0; /* … */ __Pyx_TraceLine(2627,0,__PYX_ERR(0, 2627, __pyx_L6_error)) __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2627, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+2628: flags=re.IGNORECASE).group() if bool(
__Pyx_TraceLine(2628,0,__PYX_ERR(0, 2628, __pyx_L6_error)) if ((!(!__pyx_t_5))) { /* … */ __Pyx_TraceLine(2628,0,__PYX_ERR(0, 2628, __pyx_L6_error)) __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2628, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_re); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2628, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2628, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_flags, __pyx_t_13) < 0) __PYX_ERR(0, 2628, __pyx_L6_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; /* … */ __Pyx_TraceLine(2628,0,__PYX_ERR(0, 2628, __pyx_L6_error)) __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_group); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2628, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2628, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_9 = __pyx_t_10; __pyx_t_10 = 0; } else {
+2629: re.search(r'\d', os.path.basename(obj.edifile)))
__Pyx_TraceLine(2629,0,__PYX_ERR(0, 2629, __pyx_L6_error)) __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_re); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_search); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_os); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_path); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_basename); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr32__pyx_v_obj, __pyx_n_s_edifile); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_13 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_14}; __pyx_t_15 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_kp_u_d, __pyx_t_15}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2629, __pyx_L6_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+2630: else float(ii) ,
__Pyx_TraceLine(2630,0,__PYX_ERR(0, 2630, __pyx_L6_error)) __pyx_t_10 = __Pyx_PyNumber_Float(__pyx_9genexpr32__pyx_v_ii); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2630, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __pyx_t_10; __pyx_t_10 = 0; } if (PyDict_SetItem(__pyx_t_8, __pyx_n_u_index, __pyx_t_9) < 0) __PYX_ERR(0, 2616, __pyx_L6_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 2615, __pyx_L6_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2631: }
+2632: for ii, obj in enumerate (ediObjs)
__Pyx_TraceLine(2632,0,__PYX_ERR(0, 2632, __pyx_L6_error)) if (likely(PyList_CheckExact(__pyx_v_ediObjs)) || PyTuple_CheckExact(__pyx_v_ediObjs)) { __pyx_t_2 = __pyx_v_ediObjs; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_ediObjs); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2632, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2632, __pyx_L6_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2632, __pyx_L6_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 2632, __pyx_L6_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2632, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2632, __pyx_L6_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 2632, __pyx_L6_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2632, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2632, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_9genexpr32__pyx_v_obj, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_9genexpr32__pyx_v_ii, __pyx_t_1); __pyx_t_8 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2632, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_8; __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(2632,0,__PYX_ERR(0, 2632, __pyx_L6_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr32__pyx_v_ii); __pyx_9genexpr32__pyx_v_ii = 0; __Pyx_XDECREF(__pyx_9genexpr32__pyx_v_obj); __pyx_9genexpr32__pyx_v_obj = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr32__pyx_v_ii); __pyx_9genexpr32__pyx_v_ii = 0; __Pyx_XDECREF(__pyx_9genexpr32__pyx_v_obj); __pyx_9genexpr32__pyx_v_obj = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __pyx_v_stations = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
2633: ]
2634:
+2635: ll=( 'longitude', 'latitude')
__Pyx_TraceLine(2635,0,__PYX_ERR(0, 2635, __pyx_L1_error)) __Pyx_INCREF(__pyx_tuple__139); __Pyx_GIVEREF(__pyx_tuple__139); __pyx_cur_scope->__pyx_v_ll = __pyx_tuple__139; /* … */ __pyx_tuple__139 = PyTuple_Pack(2, __pyx_n_u_longitude, __pyx_n_u_latitude); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 2635, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__139); __Pyx_GIVEREF(__pyx_tuple__139);
2636:
+2637: by = 'index' or str(by ).lower()
__Pyx_TraceLine(2637,0,__PYX_ERR(0, 2637, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_index); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_by); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_by, __pyx_n_u_index); __Pyx_GIVEREF(__pyx_n_u_index);
+2638: if ( by.find ('ll')>=0 or by.find ('lonlat')>=0):
__Pyx_TraceLine(2638,0,__PYX_ERR(0, 2638, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_by, __pyx_n_s_find); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_ll}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_17 < 0))) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!__pyx_t_17) { } else { __pyx_t_5 = __pyx_t_17; goto __pyx_L12_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_by, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_lonlat}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_17 < 0))) __PYX_ERR(0, 2638, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __pyx_t_17; __pyx_L12_bool_binop_done:; if (__pyx_t_5) { /* … */ goto __pyx_L11; }
+2639: by ='ll'
__Pyx_TraceLine(2639,0,__PYX_ERR(0, 2639, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_ll); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_by); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_by, __pyx_n_u_ll); __Pyx_GIVEREF(__pyx_n_u_ll);
+2640: elif by.find ('latlon')>=0:
__Pyx_TraceLine(2640,0,__PYX_ERR(0, 2640, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_by, __pyx_n_s_find); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_latlon}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2640, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2640, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ } __pyx_L11:;
+2641: ll =ll[::-1] # reverse
__Pyx_TraceLine(2641,0,__PYX_ERR(0, 2641, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_ll, __pyx_slice__107); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ll); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_ll, ((PyObject*)__pyx_t_1)); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
2642:
2643: # sorted from key
+2644: sorted_stations = sorted (
__Pyx_TraceLine(2644,0,__PYX_ERR(0, 2644, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_stations); __Pyx_GIVEREF(__pyx_v_stations); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stations)) __PYX_ERR(0, 2644, __pyx_L1_error); /* … */ __Pyx_TraceLine(2644,0,__PYX_ERR(0, 2644, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_sorted_stations = __pyx_t_2; __pyx_t_2 = 0;
+2645: stations , key = lambda o: (o[ll[0]], [ll[-1]])
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_lambda6(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_7_fit_ll_lambda6 = {"lambda6", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_lambda6, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_lambda6(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_o = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda6 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2645, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda6") < 0)) __PYX_ERR(0, 2645, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_o = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda6", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2645, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils._fit_ll.lambda6", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda6(__pyx_self, __pyx_v_o);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda6(PyObject *__pyx_self, PyObject *__pyx_v_o) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_10__fit_ll *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda6", __pyx_f[0], 2645, 0, __PYX_ERR(0, 2645, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(2645,0,__PYX_ERR(0, 2645, __pyx_L1_error))
if (unlikely(!__pyx_cur_scope->__pyx_v_ll)) { __Pyx_RaiseClosureNameError("ll"); __PYX_ERR(0, 2645, __pyx_L1_error) }
if (unlikely(__pyx_cur_scope->__pyx_v_ll == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(0, 2645, __pyx_L1_error)
}
__pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_ll, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_o, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_cur_scope->__pyx_v_ll)) { __Pyx_RaiseClosureNameError("ll"); __PYX_ERR(0, 2645, __pyx_L1_error) }
if (unlikely(__pyx_cur_scope->__pyx_v_ll == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
__PYX_ERR(0, 2645, __pyx_L1_error)
}
__pyx_t_4 = __Pyx_GetItemInt_Tuple(__pyx_cur_scope->__pyx_v_ll, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_GIVEREF(__pyx_t_4);
if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_4)) __PYX_ERR(0, 2645, __pyx_L1_error);
__pyx_t_4 = 0;
__pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_5);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5)) __PYX_ERR(0, 2645, __pyx_L1_error);
__Pyx_GIVEREF(__pyx_t_6);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6)) __PYX_ERR(0, 2645, __pyx_L1_error);
__pyx_t_5 = 0;
__pyx_t_6 = 0;
__pyx_t_1 = __pyx_t_4;
__pyx_t_4 = 0;
} else {
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils._fit_ll.lambda6", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2645,0,__PYX_ERR(0, 2645, __pyx_L1_error))
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_7_fit_ll_lambda6, 0, __pyx_n_s_fit_ll_locals_lambda_2, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_t_2) < 0) __PYX_ERR(0, 2645, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2646: if (by =='ll' or by=='latlon')
__Pyx_TraceLine(2646,0,__PYX_ERR(0, 2646, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_by)) { __Pyx_RaiseClosureNameError("by"); __PYX_ERR(0, 2646, __pyx_L1_error) } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_by, __pyx_n_u_ll, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2646, __pyx_L1_error) if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L3_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_by)) { __Pyx_RaiseClosureNameError("by"); __PYX_ERR(0, 2646, __pyx_L1_error) } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_by, __pyx_n_u_latlon, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2646, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L3_bool_binop_done:; if (__pyx_t_2) {
+2647: else o[by]
__Pyx_TraceLine(2647,0,__PYX_ERR(0, 2647, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_by)) { __Pyx_RaiseClosureNameError("by"); __PYX_ERR(0, 2647, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_o, __pyx_cur_scope->__pyx_v_by); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2647, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2648: )
2649:
+2650: objnames = np.array( list(
__Pyx_TraceLine(2650,0,__PYX_ERR(0, 2650, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(2650,0,__PYX_ERR(0, 2650, __pyx_L1_error)) __pyx_t_8 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_objnames = __pyx_t_2; __pyx_t_2 = 0;
+2651: map ( lambda o : o['name'], sorted_stations)))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_1lambda7(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_7_fit_ll_1lambda7 = {"lambda7", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_1lambda7, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_1lambda7(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_o = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda7 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2651, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda7") < 0)) __PYX_ERR(0, 2651, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_o = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda7", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2651, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils._fit_ll.lambda7", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda7(__pyx_self, __pyx_v_o);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda7(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_o) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda7", __pyx_f[0], 2651, 0, __PYX_ERR(0, 2651, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_o, __pyx_n_u_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2651, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("gofast.tools.coreutils._fit_ll.lambda7", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2651,0,__PYX_ERR(0, 2651, __pyx_L1_error))
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_7_fit_ll_1lambda7, 0, __pyx_n_s_fit_ll_locals_lambda_2, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2651, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2651, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GIVEREF(__pyx_t_3);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3)) __PYX_ERR(0, 2651, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_sorted_stations);
__Pyx_GIVEREF(__pyx_v_sorted_stations);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_sorted_stations)) __PYX_ERR(0, 2651, __pyx_L1_error);
__pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2651, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2652: ediObjs = np.array ( list(
__Pyx_TraceLine(2652,0,__PYX_ERR(0, 2652, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(2652,0,__PYX_ERR(0, 2652, __pyx_L1_error)) __pyx_t_8 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8)) __PYX_ERR(0, 2652, __pyx_L1_error); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(2652,0,__PYX_ERR(0, 2652, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_ediObjs, __pyx_t_3); __pyx_t_3 = 0;
+2653: map ( lambda o: o['obj'], sorted_stations)),
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_2lambda8(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_7_fit_ll_2lambda8 = {"lambda8", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_2lambda8, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_7_fit_ll_2lambda8(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_o = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda8 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2653, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda8") < 0)) __PYX_ERR(0, 2653, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_o = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda8", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2653, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils._fit_ll.lambda8", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda8(__pyx_self, __pyx_v_o);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda8(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_o) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda8", __pyx_f[0], 2653, 0, __PYX_ERR(0, 2653, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_o, __pyx_n_u_obj); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2653, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("gofast.tools.coreutils._fit_ll.lambda8", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2653,0,__PYX_ERR(0, 2653, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_7_fit_ll_2lambda8, 0, __pyx_n_s_fit_ll_locals_lambda_2, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2653, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2653, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GIVEREF(__pyx_t_2);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2)) __PYX_ERR(0, 2653, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_sorted_stations);
__Pyx_GIVEREF(__pyx_v_sorted_stations);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_sorted_stations)) __PYX_ERR(0, 2653, __pyx_L1_error);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2653, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+2654: dtype =object )
__Pyx_TraceLine(2654,0,__PYX_ERR(0, 2654, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, __pyx_builtin_object) < 0) __PYX_ERR(0, 2654, __pyx_L1_error)
2655:
+2656: return ediObjs, objnames
__Pyx_TraceLine(2656,0,__PYX_ERR(0, 2656, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2656, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_ediObjs); __Pyx_GIVEREF(__pyx_v_ediObjs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ediObjs)) __PYX_ERR(0, 2656, __pyx_L1_error); __Pyx_INCREF(__pyx_v_objnames); __Pyx_GIVEREF(__pyx_v_objnames); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_objnames)) __PYX_ERR(0, 2656, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
2657:
+2658: def _compute_haversine_d(lat1, lon1, lat2, lon2):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_98_compute_haversine_d(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_97_compute_haversine_d, " Sort coordinates using Haversine distance calculus. \n An isolated part of :func:`gofast.tools.coreutils._fit_by_ll"); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_98_compute_haversine_d = {"_compute_haversine_d", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_98_compute_haversine_d, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_97_compute_haversine_d}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_98_compute_haversine_d(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_lat1 = 0; PyObject *__pyx_v_lon1 = 0; PyObject *__pyx_v_lat2 = 0; PyObject *__pyx_v_lon2 = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_compute_haversine_d (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lat1,&__pyx_n_s_lon1,&__pyx_n_s_lat2,&__pyx_n_s_lon2,0}; PyObject* values[4] = {0,0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lat1)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2658, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lon1)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2658, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_compute_haversine_d", 1, 4, 4, 1); __PYX_ERR(0, 2658, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lat2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2658, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_compute_haversine_d", 1, 4, 4, 2); __PYX_ERR(0, 2658, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lon2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[3]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2658, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_compute_haversine_d", 1, 4, 4, 3); __PYX_ERR(0, 2658, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_compute_haversine_d") < 0)) __PYX_ERR(0, 2658, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 4)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); } __pyx_v_lat1 = values[0]; __pyx_v_lon1 = values[1]; __pyx_v_lat2 = values[2]; __pyx_v_lon2 = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_compute_haversine_d", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 2658, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._compute_haversine_d", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_97_compute_haversine_d(__pyx_self, __pyx_v_lat1, __pyx_v_lon1, __pyx_v_lat2, __pyx_v_lon2); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_97_compute_haversine_d(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lat1, PyObject *__pyx_v_lon1, PyObject *__pyx_v_lat2, PyObject *__pyx_v_lon2) { PyObject *__pyx_v_math = NULL; PyObject *__pyx_v_dlon = NULL; PyObject *__pyx_v_dlat = NULL; PyObject *__pyx_v_a = NULL; PyObject *__pyx_v_c = NULL; PyObject *__pyx_v_r = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__140) __Pyx_TraceCall("_compute_haversine_d", __pyx_f[0], 2658, 0, __PYX_ERR(0, 2658, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_lat1); __Pyx_INCREF(__pyx_v_lon1); __Pyx_INCREF(__pyx_v_lat2); __Pyx_INCREF(__pyx_v_lon2); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils._compute_haversine_d", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_math); __Pyx_XDECREF(__pyx_v_dlon); __Pyx_XDECREF(__pyx_v_dlat); __Pyx_XDECREF(__pyx_v_a); __Pyx_XDECREF(__pyx_v_c); __Pyx_XDECREF(__pyx_v_r); __Pyx_XDECREF(__pyx_v_lat1); __Pyx_XDECREF(__pyx_v_lon1); __Pyx_XDECREF(__pyx_v_lat2); __Pyx_XDECREF(__pyx_v_lon2); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__415 = PyTuple_Pack(10, __pyx_n_s_lat1, __pyx_n_s_lon1, __pyx_n_s_lat2, __pyx_n_s_lon2, __pyx_n_s_math, __pyx_n_s_dlon, __pyx_n_s_dlat, __pyx_n_s_a, __pyx_n_s_c_2, __pyx_n_s_r); if (unlikely(!__pyx_tuple__415)) __PYX_ERR(0, 2658, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__415); __Pyx_GIVEREF(__pyx_tuple__415); /* … */ __Pyx_TraceLine(2658,0,__PYX_ERR(0, 2658, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_98_compute_haversine_d, 0, __pyx_n_s_compute_haversine_d, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__140)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_compute_haversine_d, __pyx_t_2) < 0) __PYX_ERR(0, 2658, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__140 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__415, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_compute_haversine_d, 2658, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__140)) __PYX_ERR(0, 2658, __pyx_L1_error)
2659: """ Sort coordinates using Haversine distance calculus.
2660: An isolated part of :func:`gofast.tools.coreutils._fit_by_ll"""
2661: # get reference_lat and reference lon
2662: # get one obj randomnly and compute distance
2663: # obj_init = np.random.choice (ediObjs)
+2664: import math
__Pyx_TraceLine(2664,0,__PYX_ERR(0, 2664, __pyx_L1_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_math, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_math = __pyx_t_1; __pyx_t_1 = 0;
2665: # Define a function to calculate the distance
2666: # between two points in kilometers
2667: # def distance(lat1, lon1, lat2, lon2):
2668: # Convert degrees to radians
+2669: lat1 = math.radians(lat1)
__Pyx_TraceLine(2669,0,__PYX_ERR(0, 2669, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_radians); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_lat1}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_lat1, __pyx_t_1); __pyx_t_1 = 0;
+2670: lon1 = math.radians(lon1)
__Pyx_TraceLine(2670,0,__PYX_ERR(0, 2670, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_radians); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_lon1}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_lon1, __pyx_t_1); __pyx_t_1 = 0;
+2671: lat2 = math.radians(lat2)
__Pyx_TraceLine(2671,0,__PYX_ERR(0, 2671, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_radians); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_lat2}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_lat2, __pyx_t_1); __pyx_t_1 = 0;
+2672: lon2 = math.radians(lon2)
__Pyx_TraceLine(2672,0,__PYX_ERR(0, 2672, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_radians); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_lon2}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_lon2, __pyx_t_1); __pyx_t_1 = 0;
2673:
2674: # Apply the haversine formula
+2675: dlon = lon2 - lon1
__Pyx_TraceLine(2675,0,__PYX_ERR(0, 2675, __pyx_L1_error)) __pyx_t_1 = PyNumber_Subtract(__pyx_v_lon2, __pyx_v_lon1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2675, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_dlon = __pyx_t_1; __pyx_t_1 = 0;
+2676: dlat = lat2 - lat1
__Pyx_TraceLine(2676,0,__PYX_ERR(0, 2676, __pyx_L1_error)) __pyx_t_1 = PyNumber_Subtract(__pyx_v_lat2, __pyx_v_lat1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_dlat = __pyx_t_1; __pyx_t_1 = 0;
+2677: a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(
__Pyx_TraceLine(2677,0,__PYX_ERR(0, 2677, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_sin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_dlat, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyNumber_Power(__pyx_t_1, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_cos); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_lat1}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_cos); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(2677,0,__PYX_ERR(0, 2677, __pyx_L1_error)) __pyx_t_5 = PyNumber_Multiply(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(2677,0,__PYX_ERR(0, 2677, __pyx_L1_error)) __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_a = __pyx_t_1; __pyx_t_1 = 0;
+2678: lat2) * math.sin(dlon / 2)**2
__Pyx_TraceLine(2678,0,__PYX_ERR(0, 2678, __pyx_L1_error)) __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_lat2}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } /* … */ __Pyx_TraceLine(2678,0,__PYX_ERR(0, 2678, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_sin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyInt_TrueDivideObjC(__pyx_v_dlon, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_6}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyNumber_Power(__pyx_t_3, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Multiply(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+2679: c = 2 * math.asin(math.sqrt(a))
__Pyx_TraceLine(2679,0,__PYX_ERR(0, 2679, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_asin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_a}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_2}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyInt_MultiplyCObj(__pyx_int_2, __pyx_t_1, 2, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_c = __pyx_t_3; __pyx_t_3 = 0;
+2680: r = 6371 # Earth's radius in kilometers
__Pyx_TraceLine(2680,0,__PYX_ERR(0, 2680, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_6371); __pyx_v_r = __pyx_int_6371;
2681:
+2682: return c * r
__Pyx_TraceLine(2682,0,__PYX_ERR(0, 2682, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyNumber_Multiply(__pyx_v_c, __pyx_v_r); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
2683:
2684:
+2685: def make_ids(arr, prefix =None, how ='py', skip=False):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_100make_ids(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_99make_ids, " Generate auto Id according to the number of given sites. \n \n :param arr: Iterable object to generate an id site . For instance it can be \n the array-like or list of EDI object that composed a collection of \n gofast.edi.Edi object. \n :type ediObjs: array-like, list or tuple \n\n :param prefix: string value to add as prefix of given id. Prefix can be \n the site name.\n :type prefix: str \n \n :param how: Mode to index the station. Default is 'Python indexing' i.e. \n the counting starts by 0. Any other mode will start the counting by 1.\n :type cmode: str \n \n :param skip: skip the long formatage. the formatage acccording to the \n number of collected file. \n :type skip: bool \n :return: ID number formated \n :rtype: list \n \n :Example: \n >>> import numpy as np \n >>> from gofast.tools.func_utils import make_ids \n >>> values = ['edi1', 'edi2', 'edi3'] \n >>> make_ids (values, 'ix')\n ... ['ix0', 'ix1', 'ix2']\n >>> data = np.random.randn(20)\n >>> make_ids (data, prefix ='line', how=None)\n ... ['line01','line02','line03', ... , line20] \n >>> make_ids (data, prefix ='line', how=None, skip =True)\n ... ['line1','line2','line3',..., line20] \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_100make_ids = {"make_ids", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_100make_ids, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_99make_ids}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_100make_ids(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_prefix = 0; PyObject *__pyx_v_how = 0; PyObject *__pyx_v_skip = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_ids (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_prefix,&__pyx_n_s_how,&__pyx_n_s_skip,0}; PyObject* values[4] = {0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_py))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2685, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_prefix); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2685, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_how); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2685, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_skip); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2685, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "make_ids") < 0)) __PYX_ERR(0, 2685, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_prefix = values[1]; __pyx_v_how = values[2]; __pyx_v_skip = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("make_ids", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 2685, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.make_ids", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_99make_ids(__pyx_self, __pyx_v_arr, __pyx_v_prefix, __pyx_v_how, __pyx_v_skip); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_99make_ids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_prefix, PyObject *__pyx_v_how, PyObject *__pyx_v_skip) { PyObject *__pyx_v_fm = NULL; PyObject *__pyx_v_id_ = NULL; Py_ssize_t __pyx_9genexpr33__pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__141) __Pyx_TraceCall("make_ids", __pyx_f[0], 2685, 0, __PYX_ERR(0, 2685, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.make_ids", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_fm); __Pyx_XDECREF(__pyx_v_id_); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__416 = PyTuple_Pack(7, __pyx_n_s_arr, __pyx_n_s_prefix, __pyx_n_s_how, __pyx_n_s_skip, __pyx_n_s_fm, __pyx_n_s_id, __pyx_n_s_i); if (unlikely(!__pyx_tuple__416)) __PYX_ERR(0, 2685, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__416); __Pyx_GIVEREF(__pyx_tuple__416); __pyx_codeobj__141 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__416, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_make_ids, 2685, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__141)) __PYX_ERR(0, 2685, __pyx_L1_error) /* … */ __Pyx_TraceLine(2685,0,__PYX_ERR(0, 2685, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_100make_ids, 0, __pyx_n_s_make_ids, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__141)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__417); if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_ids, __pyx_t_2) < 0) __PYX_ERR(0, 2685, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__417 = PyTuple_Pack(3, Py_None, ((PyObject*)__pyx_n_u_py), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__417)) __PYX_ERR(0, 2685, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__417); __Pyx_GIVEREF(__pyx_tuple__417);
2686: """ Generate auto Id according to the number of given sites.
2687:
2688: :param arr: Iterable object to generate an id site . For instance it can be
2689: the array-like or list of EDI object that composed a collection of
2690: gofast.edi.Edi object.
2691: :type ediObjs: array-like, list or tuple
2692:
2693: :param prefix: string value to add as prefix of given id. Prefix can be
2694: the site name.
2695: :type prefix: str
2696:
2697: :param how: Mode to index the station. Default is 'Python indexing' i.e.
2698: the counting starts by 0. Any other mode will start the counting by 1.
2699: :type cmode: str
2700:
2701: :param skip: skip the long formatage. the formatage acccording to the
2702: number of collected file.
2703: :type skip: bool
2704: :return: ID number formated
2705: :rtype: list
2706:
2707: :Example:
2708: >>> import numpy as np
2709: >>> from gofast.tools.func_utils import make_ids
2710: >>> values = ['edi1', 'edi2', 'edi3']
2711: >>> make_ids (values, 'ix')
2712: ... ['ix0', 'ix1', 'ix2']
2713: >>> data = np.random.randn(20)
2714: >>> make_ids (data, prefix ='line', how=None)
2715: ... ['line01','line02','line03', ... , line20]
2716: >>> make_ids (data, prefix ='line', how=None, skip =True)
2717: ... ['line1','line2','line3',..., line20]
2718:
2719: """
+2720: fm='{:0' + ('1' if skip else '{}'.format(int(np.log10(len(arr))) + 1)) +'}'
__Pyx_TraceLine(2720,0,__PYX_ERR(0, 2720, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_skip); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2720, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_kp_u_1); __pyx_t_1 = __pyx_kp_u_1; } else { __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_log10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2720, __pyx_L1_error) __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_7, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_5}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_t_3 = PyNumber_Add(__pyx_kp_u_0_3, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_kp_u__75); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2720, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_fm = __pyx_t_1; __pyx_t_1 = 0;
+2721: id_ =[str(prefix) + fm.format(i if how=='py'else i+ 1 ) if prefix is not
__Pyx_TraceLine(2721,0,__PYX_ERR(0, 2721, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(2721,0,__PYX_ERR(0, 2721, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Str(__pyx_v_prefix); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_fm, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_how, __pyx_n_u_py, Py_EQ)); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 2721, __pyx_L1_error) if (__pyx_t_13) { __pyx_t_9 = PyInt_FromSsize_t(__pyx_9genexpr33__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __pyx_t_9; __pyx_t_9 = 0; } else { __pyx_t_9 = PyInt_FromSsize_t((__pyx_9genexpr33__pyx_v_i + 1)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_t_9 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __pyx_t_7; __pyx_t_7 = 0; } else {
+2722: None else fm.format(i if how=='py'else i+ 1)
__Pyx_TraceLine(2722,0,__PYX_ERR(0, 2722, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_prefix != Py_None); if (__pyx_t_2) { /* … */ __Pyx_TraceLine(2722,0,__PYX_ERR(0, 2722, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_fm, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_v_how, __pyx_n_u_py, Py_EQ)); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 2722, __pyx_L1_error) if (__pyx_t_13) { __pyx_t_6 = PyInt_FromSsize_t(__pyx_9genexpr33__pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __pyx_t_6; __pyx_t_6 = 0; } else { __pyx_t_6 = PyInt_FromSsize_t((__pyx_9genexpr33__pyx_v_i + 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_t_6 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_3 = __pyx_t_7; __pyx_t_7 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 2721, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } } /* exit inner scope */ __pyx_v_id_ = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+2723: for i in range(len(arr))]
__Pyx_TraceLine(2723,0,__PYX_ERR(0, 2723, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2723, __pyx_L1_error) __pyx_t_11 = __pyx_t_8; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_9genexpr33__pyx_v_i = __pyx_t_12;
+2724: return id_
__Pyx_TraceLine(2724,0,__PYX_ERR(0, 2724, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_id_); __pyx_r = __pyx_v_id_; goto __pyx_L0;
2725:
+2726: def show_stats(nedic , nedir, fmtl='~', lenl=77, obj='EDI'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_102show_stats(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_101show_stats, " Estimate the file successfully read reading over the unread files\n\n :param nedic: number of input or collected files \n :param nedir: number of files read sucessfully \n :param fmt: str to format the stats line \n :param lenl: length of line denileation."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_102show_stats = {"show_stats", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_102show_stats, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_101show_stats}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_102show_stats(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_nedic = 0; PyObject *__pyx_v_nedir = 0; PyObject *__pyx_v_fmtl = 0; PyObject *__pyx_v_lenl = 0; PyObject *__pyx_v_obj = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("show_stats (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_nedic,&__pyx_n_s_nedir,&__pyx_n_s_fmtl,&__pyx_n_s_lenl,&__pyx_n_s_obj,0}; PyObject* values[5] = {0,0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__70))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_77))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_EDI))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_nedic)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2726, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_nedir)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2726, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("show_stats", 0, 2, 5, 1); __PYX_ERR(0, 2726, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fmtl); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2726, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lenl); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2726, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2726, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "show_stats") < 0)) __PYX_ERR(0, 2726, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_nedic = values[0]; __pyx_v_nedir = values[1]; __pyx_v_fmtl = values[2]; __pyx_v_lenl = values[3]; __pyx_v_obj = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("show_stats", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 2726, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.show_stats", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_101show_stats(__pyx_self, __pyx_v_nedic, __pyx_v_nedir, __pyx_v_fmtl, __pyx_v_lenl, __pyx_v_obj); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_101show_stats(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_nedic, PyObject *__pyx_v_nedir, PyObject *__pyx_v_fmtl, PyObject *__pyx_v_lenl, PyObject *__pyx_v_obj) { PyObject *__pyx_v_get_obj_len = 0; PyObject *__pyx_v_mesg = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__142) __Pyx_TraceCall("show_stats", __pyx_f[0], 2726, 0, __PYX_ERR(0, 2726, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_nedic); __Pyx_INCREF(__pyx_v_nedir); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.show_stats", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_get_obj_len); __Pyx_XDECREF(__pyx_v_mesg); __Pyx_XDECREF(__pyx_v_nedic); __Pyx_XDECREF(__pyx_v_nedir); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__418 = PyTuple_Pack(8, __pyx_n_s_nedic, __pyx_n_s_nedir, __pyx_n_s_fmtl, __pyx_n_s_lenl, __pyx_n_s_obj, __pyx_n_s_get_obj_len, __pyx_n_s_get_obj_len, __pyx_n_s_mesg); if (unlikely(!__pyx_tuple__418)) __PYX_ERR(0, 2726, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__418); __Pyx_GIVEREF(__pyx_tuple__418); __pyx_codeobj__142 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__418, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_show_stats, 2726, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__142)) __PYX_ERR(0, 2726, __pyx_L1_error) /* … */ __Pyx_TraceLine(2726,0,__PYX_ERR(0, 2726, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_102show_stats, 0, __pyx_n_s_show_stats, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__142)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__419); if (PyDict_SetItem(__pyx_d, __pyx_n_s_show_stats, __pyx_t_2) < 0) __PYX_ERR(0, 2726, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__419 = PyTuple_Pack(3, ((PyObject*)__pyx_kp_u__70), ((PyObject *)__pyx_int_77), ((PyObject*)__pyx_n_u_EDI)); if (unlikely(!__pyx_tuple__419)) __PYX_ERR(0, 2726, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__419); __Pyx_GIVEREF(__pyx_tuple__419);
2727: """ Estimate the file successfully read reading over the unread files
2728:
2729: :param nedic: number of input or collected files
2730: :param nedir: number of files read sucessfully
2731: :param fmt: str to format the stats line
2732: :param lenl: length of line denileation."""
2733:
+2734: def get_obj_len (value):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_10show_stats_1get_obj_len(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_10show_stats_get_obj_len, " Control if obj is iterable then take its length "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_10show_stats_1get_obj_len = {"get_obj_len", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_10show_stats_1get_obj_len, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_10show_stats_get_obj_len}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_10show_stats_1get_obj_len(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_value = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_obj_len (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2734, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_obj_len") < 0)) __PYX_ERR(0, 2734, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_value = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_obj_len", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2734, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.show_stats.get_obj_len", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_10show_stats_get_obj_len(__pyx_self, __pyx_v_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_10show_stats_get_obj_len(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("get_obj_len", __pyx_f[0], 2734, 0, __PYX_ERR(0, 2734, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_value); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.show_stats.get_obj_len", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__143 = PyTuple_Pack(1, __pyx_n_s_value); if (unlikely(!__pyx_tuple__143)) __PYX_ERR(0, 2734, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__143); __Pyx_GIVEREF(__pyx_tuple__143); /* … */ __Pyx_TraceLine(2734,0,__PYX_ERR(0, 2734, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_10show_stats_1get_obj_len, 0, __pyx_n_s_show_stats_locals_get_obj_len, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__144)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2734, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_get_obj_len = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__144 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__143, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_obj_len, 2734, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__144)) __PYX_ERR(0, 2734, __pyx_L1_error)
2735: """ Control if obj is iterable then take its length """
+2736: try :
__Pyx_TraceLine(2736,0,__PYX_ERR(0, 2736, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_L8_try_end:; }
+2737: iter(value)
__Pyx_TraceLine(2737,0,__PYX_ERR(0, 2737, __pyx_L3_error)) __pyx_t_4 = PyObject_GetIter(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2737, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2738: except :pass
__Pyx_TraceLine(2738,0,__PYX_ERR(0, 2738, __pyx_L5_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; }
+2739: else : value =len(value)
__Pyx_TraceLine(2739,0,__PYX_ERR(0, 2739, __pyx_L5_except_error)) /*else:*/ { __pyx_t_5 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2739, __pyx_L5_except_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2739, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0; } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
+2740: return value
__Pyx_TraceLine(2740,0,__PYX_ERR(0, 2740, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_value); __pyx_r = __pyx_v_value; goto __pyx_L0;
+2741: nedic = get_obj_len(nedic)
__Pyx_TraceLine(2741,0,__PYX_ERR(0, 2741, __pyx_L1_error)) __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_10show_stats_get_obj_len(__pyx_v_get_obj_len, __pyx_v_nedic); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2741, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_nedic, __pyx_t_1); __pyx_t_1 = 0;
+2742: nedir = get_obj_len(nedir)
__Pyx_TraceLine(2742,0,__PYX_ERR(0, 2742, __pyx_L1_error)) __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_10show_stats_get_obj_len(__pyx_v_get_obj_len, __pyx_v_nedir); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_nedir, __pyx_t_1); __pyx_t_1 = 0;
2743:
+2744: print(fmtl * lenl )
__Pyx_TraceLine(2744,0,__PYX_ERR(0, 2744, __pyx_L1_error)) __pyx_t_1 = PyNumber_Multiply(__pyx_v_fmtl, __pyx_v_lenl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2745: mesg ='|'.join( ['|{0:<15}{1:^2} {2:<7}',
__Pyx_TraceLine(2745,0,__PYX_ERR(0, 2745, __pyx_L1_error)) __pyx_t_2 = PyList_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_kp_u_0_15_1_2_2_7); __Pyx_GIVEREF(__pyx_kp_u_0_15_1_2_2_7); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_0_15_1_2_2_7)) __PYX_ERR(0, 2745, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_3_15_4_2_5_7); __Pyx_GIVEREF(__pyx_kp_u_3_15_4_2_5_7); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u_3_15_4_2_5_7)) __PYX_ERR(0, 2745, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_6_9_7_2_8_7); __Pyx_GIVEREF(__pyx_kp_u_6_9_7_2_8_7); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_6_9_7_2_8_7)) __PYX_ERR(0, 2745, __pyx_L1_error); __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__122, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_mesg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
2746: '{3:<15}{4:^2} {5:<7}',
2747: '{6:<9}{7:^2} {8:<7}%|'])
+2748: print(mesg.format('Data collected','=', nedic, f'{obj} success. read',
__Pyx_TraceLine(2748,0,__PYX_ERR(0, 2748, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mesg, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_obj, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_3, __pyx_kp_u_success_read); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(2748,0,__PYX_ERR(0, 2748, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+2749: '=', nedir, 'Rate','=', round ((nedir/nedic) *100, 2),
__Pyx_TraceLine(2749,0,__PYX_ERR(0, 2749, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_v_nedir, __pyx_v_nedic); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyInt_MultiplyObjC(__pyx_t_3, __pyx_int_100, 0x64, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5)) __PYX_ERR(0, 2749, __pyx_L1_error); __Pyx_INCREF(__pyx_int_2); __Pyx_GIVEREF(__pyx_int_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_2)) __PYX_ERR(0, 2749, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_round, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[11] = {__pyx_t_3, __pyx_kp_u_Data_collected, __pyx_kp_u__54, __pyx_v_nedic, __pyx_t_4, __pyx_kp_u__54, __pyx_v_nedir, __pyx_n_u_Rate, __pyx_kp_u__54, __pyx_t_5, __pyx_int_2}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 10+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; }
2750: 2))
+2751: print(fmtl * lenl )
__Pyx_TraceLine(2751,0,__PYX_ERR(0, 2751, __pyx_L1_error)) __pyx_t_2 = PyNumber_Multiply(__pyx_v_fmtl, __pyx_v_lenl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2751, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2751, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2752:
+2753: def concat_array_from_list (list_of_array , concat_axis = 0) :
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_104concat_array_from_list(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_103concat_array_from_list, " Concat array from list and set the None value in the list as NaN.\n \n :param list_of_array: List of array elements \n :type list of array: list \n \n :param concat_axis: axis for concatenation ``0`` or ``1``\n :type concat_axis: int \n \n :returns: Concatenated array with shape np.ndaarry(\n len(list_of_array[0]), len(list_of_array))\n :rtype: np.ndarray \n \n :Example: \n \n >>> import numpy as np \n >>> from gofast.tools.coreutils import concat_array_from_list \n >>> np.random.seed(0)\n >>> ass=np.random.randn(10)\n >>> ass = ass2=np.linspace(0,15,10)\n >>> concat_array_from_list ([ass, ass]) \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_104concat_array_from_list = {"concat_array_from_list", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_104concat_array_from_list, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_103concat_array_from_list}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_104concat_array_from_list(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_list_of_array = 0; PyObject *__pyx_v_concat_axis = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("concat_array_from_list (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_list_of_array,&__pyx_n_s_concat_axis,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_list_of_array)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2753, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_concat_axis); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2753, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "concat_array_from_list") < 0)) __PYX_ERR(0, 2753, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_list_of_array = values[0]; __pyx_v_concat_axis = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("concat_array_from_list", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 2753, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_103concat_array_from_list(__pyx_self, __pyx_v_list_of_array, __pyx_v_concat_axis); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_103concat_array_from_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_of_array, PyObject *__pyx_v_concat_axis) { PyObject *__pyx_v_ar = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__145) __Pyx_TraceCall("concat_array_from_list", __pyx_f[0], 2753, 0, __PYX_ERR(0, 2753, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_list_of_array); __Pyx_INCREF(__pyx_v_concat_axis); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ar); __Pyx_XDECREF(__pyx_v_list_of_array); __Pyx_XDECREF(__pyx_v_concat_axis); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__420 = PyTuple_Pack(3, __pyx_n_s_list_of_array, __pyx_n_s_concat_axis, __pyx_n_s_ar); if (unlikely(!__pyx_tuple__420)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__420); __Pyx_GIVEREF(__pyx_tuple__420); /* … */ __Pyx_TraceLine(2753,0,__PYX_ERR(0, 2753, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_104concat_array_from_list, 0, __pyx_n_s_concat_array_from_list, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__145)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__352); if (PyDict_SetItem(__pyx_d, __pyx_n_s_concat_array_from_list, __pyx_t_2) < 0) __PYX_ERR(0, 2753, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__145 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__420, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_concat_array_from_list, 2753, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__145)) __PYX_ERR(0, 2753, __pyx_L1_error)
2754: """ Concat array from list and set the None value in the list as NaN.
2755:
2756: :param list_of_array: List of array elements
2757: :type list of array: list
2758:
2759: :param concat_axis: axis for concatenation ``0`` or ``1``
2760: :type concat_axis: int
2761:
2762: :returns: Concatenated array with shape np.ndaarry(
2763: len(list_of_array[0]), len(list_of_array))
2764: :rtype: np.ndarray
2765:
2766: :Example:
2767:
2768: >>> import numpy as np
2769: >>> from gofast.tools.coreutils import concat_array_from_list
2770: >>> np.random.seed(0)
2771: >>> ass=np.random.randn(10)
2772: >>> ass = ass2=np.linspace(0,15,10)
2773: >>> concat_array_from_list ([ass, ass])
2774:
2775: """
+2776: concat_axis =int(_assert_all_types(concat_axis, int, float))
__Pyx_TraceLine(2776,0,__PYX_ERR(0, 2776, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_v_concat_axis, ((PyObject *)(&PyInt_Type)), ((PyObject *)(&PyFloat_Type))}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2776, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_concat_axis, __pyx_t_2); __pyx_t_2 = 0;
+2777: if concat_axis not in (0 , 1):
__Pyx_TraceLine(2777,0,__PYX_ERR(0, 2777, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_concat_axis); __pyx_t_2 = __pyx_v_concat_axis; __pyx_t_6 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_2, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2777, __pyx_L1_error) if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2777, __pyx_L1_error) __pyx_t_5 = __pyx_t_6; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __pyx_t_5; if (unlikely(__pyx_t_6)) { /* … */ }
+2778: raise ValueError(f'Unable to understand axis: {str(concat_axis)!r}')
__Pyx_TraceLine(2778,0,__PYX_ERR(0, 2778, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_concat_axis); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Unable_to_understand_axis, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2778, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 2778, __pyx_L1_error)
2779:
+2780: list_of_array = list(map(lambda e: np.array([np.nan])
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_lambda9(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22concat_array_from_list_lambda9 = {"lambda9", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_lambda9, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_lambda9(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_e = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda9 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_e,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_e)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2780, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda9") < 0)) __PYX_ERR(0, 2780, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_e = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda9", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2780, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list.lambda9", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda9(__pyx_self, __pyx_v_e);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda9(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_e) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda9", __pyx_f[0], 2780, 0, __PYX_ERR(0, 2780, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(2780,0,__PYX_ERR(0, 2780, __pyx_L1_error))
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_GIVEREF(__pyx_t_6);
if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_6)) __PYX_ERR(0, 2780, __pyx_L1_error);
__pyx_t_6 = 0;
__pyx_t_6 = NULL;
__pyx_t_7 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_6)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
__pyx_t_7 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4};
__pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7);
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
__pyx_t_1 = __pyx_t_3;
__pyx_t_3 = 0;
} else {
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list.lambda9", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2780,0,__PYX_ERR(0, 2780, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22concat_array_from_list_lambda9, 0, __pyx_n_s_concat_array_from_list_locals_la, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
/* … */
__Pyx_TraceLine(2781,0,__PYX_ERR(0, 2781, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 2780, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_list_of_array);
__Pyx_GIVEREF(__pyx_v_list_of_array);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_list_of_array)) __PYX_ERR(0, 2780, __pyx_L1_error);
__pyx_t_1 = 0;
/* … */
__Pyx_TraceLine(2780,0,__PYX_ERR(0, 2780, __pyx_L1_error))
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2780, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF_SET(__pyx_v_list_of_array, __pyx_t_2);
__pyx_t_2 = 0;
+2781: if e is None else np.array(e), list_of_array))
__Pyx_TraceLine(2781,0,__PYX_ERR(0, 2781, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_e == Py_None); if (__pyx_t_2) { /* … */ __Pyx_TraceLine(2781,0,__PYX_ERR(0, 2781, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_e}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
2782: # if the list is composed of one element of array, keep it outside
2783: # reshape accordingly
+2784: if len(list_of_array)==1:
__Pyx_TraceLine(2784,0,__PYX_ERR(0, 2784, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_list_of_array); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2784, __pyx_L1_error) __pyx_t_6 = (__pyx_t_7 == 1); if (__pyx_t_6) { /* … */ }
+2785: ar = (list_of_array[0].reshape ((1,len(list_of_array[0]))
__Pyx_TraceLine(2785,0,__PYX_ERR(0, 2785, __pyx_L1_error)) __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_list_of_array, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_reshape); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_list_of_array, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_int_1)) __PYX_ERR(0, 2785, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_8)) __PYX_ERR(0, 2785, __pyx_L1_error); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_10}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } else {
+2786: ) if concat_axis==0 else list_of_array[0].reshape(
__Pyx_TraceLine(2786,0,__PYX_ERR(0, 2786, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_concat_axis, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2786, __pyx_L1_error) if (__pyx_t_5) { /* … */ __Pyx_TraceLine(2786,0,__PYX_ERR(0, 2786, __pyx_L1_error)) __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_list_of_array, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_reshape); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+2787: (len(list_of_array[0]), 1)
__Pyx_TraceLine(2787,0,__PYX_ERR(0, 2787, __pyx_L1_error)) __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_list_of_array, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2787, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9)) __PYX_ERR(0, 2787, __pyx_L1_error); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_int_1)) __PYX_ERR(0, 2787, __pyx_L1_error); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else {
2788: )
+2789: ) if list_of_array[0].ndim ==1 else list_of_array[0]
__Pyx_TraceLine(2789,0,__PYX_ERR(0, 2789, __pyx_L1_error)) __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_list_of_array, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_3, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { /* … */ __Pyx_TraceLine(2789,0,__PYX_ERR(0, 2789, __pyx_L1_error)) __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_list_of_array, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_ar = __pyx_t_2; __pyx_t_2 = 0;
2790:
+2791: return ar
__Pyx_TraceLine(2791,0,__PYX_ERR(0, 2791, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_ar); __pyx_r = __pyx_v_ar; goto __pyx_L0;
2792:
2793: #if concat_axis ==1:
+2794: list_of_array = list(map(
__Pyx_TraceLine(2794,0,__PYX_ERR(0, 2794, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3)) __PYX_ERR(0, 2794, __pyx_L1_error); __Pyx_INCREF(__pyx_v_list_of_array); __Pyx_GIVEREF(__pyx_v_list_of_array); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_list_of_array)) __PYX_ERR(0, 2794, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2794, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; } else {
+2795: lambda e:e.reshape(e.shape[0], 1) if e.ndim ==1 else e ,
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_1lambda10(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22concat_array_from_list_1lambda10 = {"lambda10", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_1lambda10, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_1lambda10(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_e = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda10 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_e,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_e)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2795, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda10") < 0)) __PYX_ERR(0, 2795, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_e = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda10", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2795, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list.lambda10", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda10(__pyx_self, __pyx_v_e);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda10(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_e) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda10", __pyx_f[0], 2795, 0, __PYX_ERR(0, 2795, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_3) {
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = NULL;
__pyx_t_7 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
__pyx_t_7 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_6, __pyx_int_1};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
}
__pyx_t_1 = __pyx_t_2;
__pyx_t_2 = 0;
} else {
__Pyx_INCREF(__pyx_v_e);
__pyx_t_1 = __pyx_v_e;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list.lambda10", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2795,0,__PYX_ERR(0, 2795, __pyx_L1_error))
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22concat_array_from_list_1lambda10, 0, __pyx_n_s_concat_array_from_list_locals_la, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2795, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
2796: list_of_array)
+2797: ) if concat_axis ==1 else list(map(
__Pyx_TraceLine(2797,0,__PYX_ERR(0, 2797, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_concat_axis, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2797, __pyx_L1_error) if (__pyx_t_6) { /* … */ __Pyx_TraceLine(2797,0,__PYX_ERR(0, 2797, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1)) __PYX_ERR(0, 2797, __pyx_L1_error); __Pyx_INCREF(__pyx_v_list_of_array); __Pyx_GIVEREF(__pyx_v_list_of_array); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_list_of_array)) __PYX_ERR(0, 2797, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2797, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_list_of_array, __pyx_t_2); __pyx_t_2 = 0;
+2798: lambda e:e.reshape(1, e.shape[0]) if e.ndim ==1 else e ,
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_2lambda11(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22concat_array_from_list_2lambda11 = {"lambda11", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_2lambda11, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22concat_array_from_list_2lambda11(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_e = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda11 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_e,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_e)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2798, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda11") < 0)) __PYX_ERR(0, 2798, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_e = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda11", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2798, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list.lambda11", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda11(__pyx_self, __pyx_v_e);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda11(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_e) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda11", __pyx_f[0], 2798, 0, __PYX_ERR(0, 2798, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_3) {
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_reshape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = NULL;
__pyx_t_7 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
__pyx_t_7 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_int_1, __pyx_t_6};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
}
__pyx_t_1 = __pyx_t_2;
__pyx_t_2 = 0;
} else {
__Pyx_INCREF(__pyx_v_e);
__pyx_t_1 = __pyx_v_e;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.concat_array_from_list.lambda11", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2798,0,__PYX_ERR(0, 2798, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22concat_array_from_list_2lambda11, 0, __pyx_n_s_concat_array_from_list_locals_la, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2798, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
2799: list_of_array))
2800:
+2801: return np.concatenate(list_of_array, axis = concat_axis)
__Pyx_TraceLine(2801,0,__PYX_ERR(0, 2801, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2801, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2801, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2801, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_list_of_array); __Pyx_GIVEREF(__pyx_v_list_of_array); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_list_of_array)) __PYX_ERR(0, 2801, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2801, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_axis, __pyx_v_concat_axis) < 0) __PYX_ERR(0, 2801, __pyx_L1_error) __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2801, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0;
2802:
+2803: def station_id (id_, is_index= 'index', how=None, **kws):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_106station_id(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_105station_id, " \n From id get the station name as input and return index `id`. \n Index starts at 0.\n \n :param id_: str, of list of the name of the station or indexes . \n \n :param is_index: bool \n considered the given station as a index. so it remove all the letter and\n keep digit as index of each stations. \n \n :param how: Mode to index the station. Default is \n 'Python indexing' i.e.the counting starts by 0. Any other mode will \n start the counting by 1. Note that if `is_index` is ``True`` and the \n param `how` is set to it default value ``py``, the station index should \n be downgraded to 1. \n \n :param kws: additionnal keywords arguments from :func:`~.make_ids`.\n \n :return: station index. If the list `id_` is given will return the tuple.\n \n :Example:\n \n >>> from gofast.tools.coreutils import station_id \n >>> dat1 = ['S13', 's02', 's85', 'pk20', 'posix1256']\n >>> station_id (dat1)\n ... (13, 2, 85, 20, 1256)\n >>> station_id (dat1, how='py')\n ... (12, 1, 84, 19, 1255)\n >>> station_id (dat1, is_index= None, prefix ='site')\n ... ('site1', 'site2', 'site3', 'site4', 'site5')\n >>> dat2 = 1 \n >>> station_id (dat2) # return index like it is\n ... 1\n >>> station_id (dat2, how='py') # considering the index starts from 0\n ... 0\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_106station_id = {"station_id", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_106station_id, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_105station_id}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_106station_id(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_id_ = 0; PyObject *__pyx_v_is_index = 0; PyObject *__pyx_v_how = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("station_id (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_id,&__pyx_n_s_is_index,&__pyx_n_s_how,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_index))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_id)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2803, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_is_index); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2803, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_how); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2803, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "station_id") < 0)) __PYX_ERR(0, 2803, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_id_ = values[0]; __pyx_v_is_index = values[1]; __pyx_v_how = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("station_id", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 2803, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.station_id", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_105station_id(__pyx_self, __pyx_v_id_, __pyx_v_is_index, __pyx_v_how, __pyx_v_kws); /* function exit code */ __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_105station_id(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_id_, PyObject *__pyx_v_is_index, PyObject *__pyx_v_how, PyObject *__pyx_v_kws) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id *__pyx_cur_scope; int __pyx_v_is_iterable; int __pyx_v_isix; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__146) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 2803, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("station_id", __pyx_f[0], 2803, 0, __PYX_ERR(0, 2803, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_id_); __Pyx_INCREF(__pyx_v_is_index); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils.station_id", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_id_); __Pyx_XDECREF(__pyx_v_is_index); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__421 = PyTuple_Pack(7, __pyx_n_s_id, __pyx_n_s_is_index, __pyx_n_s_how, __pyx_n_s_kws_2, __pyx_n_s_is_iterable, __pyx_n_s_isix, __pyx_n_s_regex); if (unlikely(!__pyx_tuple__421)) __PYX_ERR(0, 2803, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__421); __Pyx_GIVEREF(__pyx_tuple__421); __pyx_codeobj__146 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__421, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_station_id, 2803, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__146)) __PYX_ERR(0, 2803, __pyx_L1_error) /* … */ __Pyx_TraceLine(2803,0,__PYX_ERR(0, 2803, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_106station_id, 0, __pyx_n_s_station_id, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__146)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2803, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__422); if (PyDict_SetItem(__pyx_d, __pyx_n_s_station_id, __pyx_t_2) < 0) __PYX_ERR(0, 2803, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__422 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u_index), Py_None); if (unlikely(!__pyx_tuple__422)) __PYX_ERR(0, 2803, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__422); __Pyx_GIVEREF(__pyx_tuple__422); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id { PyObject_HEAD PyObject *__pyx_v_regex; };
2804: """
2805: From id get the station name as input and return index `id`.
2806: Index starts at 0.
2807:
2808: :param id_: str, of list of the name of the station or indexes .
2809:
2810: :param is_index: bool
2811: considered the given station as a index. so it remove all the letter and
2812: keep digit as index of each stations.
2813:
2814: :param how: Mode to index the station. Default is
2815: 'Python indexing' i.e.the counting starts by 0. Any other mode will
2816: start the counting by 1. Note that if `is_index` is ``True`` and the
2817: param `how` is set to it default value ``py``, the station index should
2818: be downgraded to 1.
2819:
2820: :param kws: additionnal keywords arguments from :func:`~.make_ids`.
2821:
2822: :return: station index. If the list `id_` is given will return the tuple.
2823:
2824: :Example:
2825:
2826: >>> from gofast.tools.coreutils import station_id
2827: >>> dat1 = ['S13', 's02', 's85', 'pk20', 'posix1256']
2828: >>> station_id (dat1)
2829: ... (13, 2, 85, 20, 1256)
2830: >>> station_id (dat1, how='py')
2831: ... (12, 1, 84, 19, 1255)
2832: >>> station_id (dat1, is_index= None, prefix ='site')
2833: ... ('site1', 'site2', 'site3', 'site4', 'site5')
2834: >>> dat2 = 1
2835: >>> station_id (dat2) # return index like it is
2836: ... 1
2837: >>> station_id (dat2, how='py') # considering the index starts from 0
2838: ... 0
2839:
2840: """
+2841: is_iterable =False
__Pyx_TraceLine(2841,0,__PYX_ERR(0, 2841, __pyx_L1_error)) __pyx_v_is_iterable = 0;
+2842: is_index = str(is_index).lower().strip()
__Pyx_TraceLine(2842,0,__PYX_ERR(0, 2842, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_is_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_is_index, __pyx_t_1); __pyx_t_1 = 0;
+2843: isix=True if is_index in ('true', 'index', 'yes', 'ix') else False
__Pyx_TraceLine(2843,0,__PYX_ERR(0, 2843, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_is_index); __pyx_t_1 = __pyx_v_is_index; __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_true, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2843, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L3_bool_binop_done; } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_index, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2843, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L3_bool_binop_done; } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_yes, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2843, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L3_bool_binop_done; } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_ix, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2843, __pyx_L1_error) __pyx_t_7 = __pyx_t_8; __pyx_L3_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __pyx_t_7; if (__pyx_t_8) { __pyx_t_6 = 1; } else { __pyx_t_6 = 0; } __pyx_v_isix = __pyx_t_6;
2844:
+2845: regex = re.compile(r'\d+', flags=re.IGNORECASE)
__Pyx_TraceLine(2845,0,__PYX_ERR(0, 2845, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_flags, __pyx_t_3) < 0) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__147, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_regex = __pyx_t_3; __pyx_t_3 = 0; /* … */ __pyx_tuple__147 = PyTuple_Pack(1, __pyx_kp_u_d_2); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(0, 2845, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__147); __Pyx_GIVEREF(__pyx_tuple__147);
+2846: try :
__Pyx_TraceLine(2846,0,__PYX_ERR(0, 2846, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); __pyx_L12_try_end:; }
+2847: iter (id_)
__Pyx_TraceLine(2847,0,__PYX_ERR(0, 2847, __pyx_L7_error)) __pyx_t_3 = PyObject_GetIter(__pyx_v_id_); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2847, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2848: except :
__Pyx_TraceLine(2848,0,__PYX_ERR(0, 2848, __pyx_L9_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.station_id", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 2848, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4);
+2849: id_= [id_]
__Pyx_TraceLine(2849,0,__PYX_ERR(0, 2849, __pyx_L9_except_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2849, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_id_); __Pyx_GIVEREF(__pyx_v_id_); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_id_)) __PYX_ERR(0, 2849, __pyx_L9_except_error); __Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L8_exception_handled; }
+2850: else : is_iterable=True
__Pyx_TraceLine(2850,0,__PYX_ERR(0, 2850, __pyx_L9_except_error)) /*else:*/ { __pyx_v_is_iterable = 1; } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2851:
2852: #remove all the letter
+2853: id_= list(map( lambda o: regex.findall(o), list(map(str, id_))))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_10station_id_lambda12(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_10station_id_lambda12 = {"lambda12", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_10station_id_lambda12, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_10station_id_lambda12(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_o = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda12 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2853, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda12") < 0)) __PYX_ERR(0, 2853, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_o = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda12", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2853, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.station_id.lambda12", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda12(__pyx_self, __pyx_v_o);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda12(PyObject *__pyx_self, PyObject *__pyx_v_o) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_11_station_id *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda12", __pyx_f[0], 2853, 0, __PYX_ERR(0, 2853, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_regex)) { __Pyx_RaiseClosureNameError("regex"); __PYX_ERR(0, 2853, __pyx_L1_error) }
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_regex, __pyx_n_s_findall); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = NULL;
__pyx_t_4 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_3)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_4 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_o};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("gofast.tools.coreutils.station_id.lambda12", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(2853,0,__PYX_ERR(0, 2853, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_10station_id_lambda12, 0, __pyx_n_s_station_id_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF((PyObject *)(&PyUnicode_Type));
__Pyx_GIVEREF((PyObject *)(&PyUnicode_Type));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyUnicode_Type)))) __PYX_ERR(0, 2853, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_id_);
__Pyx_GIVEREF(__pyx_v_id_);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_id_)) __PYX_ERR(0, 2853, __pyx_L1_error);
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4)) __PYX_ERR(0, 2853, __pyx_L1_error);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error);
__pyx_t_4 = 0;
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2853, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_3);
__pyx_t_3 = 0;
2854: # merge the sequences list and for consistency remove emty list or str
+2855: id_=tuple(filter (None, list(itertools.chain(*id_))))
__Pyx_TraceLine(2855,0,__PYX_ERR(0, 2855, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_itertools); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_chain); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_id_); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, Py_None)) __PYX_ERR(0, 2855, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_filter, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2855, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_4); __pyx_t_4 = 0;
2856:
2857: # if considering as Python index return value -1 other wise return index
2858:
+2859: id_ = tuple (map(int, np.array(id_, dtype = np.int32)-1)
__Pyx_TraceLine(2859,0,__PYX_ERR(0, 2859, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_id_); __Pyx_GIVEREF(__pyx_v_id_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_id_)) __PYX_ERR(0, 2859, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_int32); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_13) < 0) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyInt_SubtractObjC(__pyx_t_13, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 2859, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_2)) __PYX_ERR(0, 2859, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2859, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_13; __pyx_t_13 = 0; } else {
+2860: ) if how =='py' else tuple ( map(int, id_))
__Pyx_TraceLine(2860,0,__PYX_ERR(0, 2860, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_how, __pyx_n_u_py, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2860, __pyx_L1_error) if (__pyx_t_6) { /* … */ __Pyx_TraceLine(2860,0,__PYX_ERR(0, 2860, __pyx_L1_error)) __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 2860, __pyx_L1_error); __Pyx_INCREF(__pyx_v_id_); __Pyx_GIVEREF(__pyx_v_id_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_id_)) __PYX_ERR(0, 2860, __pyx_L1_error); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2860, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_13; __pyx_t_13 = 0; } __Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_4); __pyx_t_4 = 0;
2861:
+2862: if (np.array(id_) < 0).any():
__Pyx_TraceLine(2862,0,__PYX_ERR(0, 2862, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_id_}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_13, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_any); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_13))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2862, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { /* … */ }
+2863: warnings.warn('Index contains negative values. Be aware that you are'
__Pyx_TraceLine(2863,0,__PYX_ERR(0, 2863, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_warnings); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_kp_u_Index_contains_negative_values_B}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2864: " using a Python indexing. Otherwise turn 'how' argumennt"
2865: " to 'None'.")
+2866: if not isix :
__Pyx_TraceLine(2866,0,__PYX_ERR(0, 2866, __pyx_L1_error)) __pyx_t_6 = (!__pyx_v_isix); if (__pyx_t_6) { /* … */ }
+2867: id_= tuple(make_ids(id_, how= how, **kws))
__Pyx_TraceLine(2867,0,__PYX_ERR(0, 2867, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_make_ids); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_id_); __Pyx_GIVEREF(__pyx_v_id_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_id_)) __PYX_ERR(0, 2867, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_how, __pyx_v_how) < 0) __PYX_ERR(0, 2867, __pyx_L1_error) __pyx_t_13 = __pyx_t_2; __pyx_t_2 = 0; if (__Pyx_MergeKeywords(__pyx_t_13, __pyx_v_kws) < 0) __PYX_ERR(0, 2867, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_13); __pyx_t_13 = 0;
2868:
+2869: if not is_iterable :
__Pyx_TraceLine(2869,0,__PYX_ERR(0, 2869, __pyx_L1_error)) __pyx_t_6 = (!__pyx_v_is_iterable); if (__pyx_t_6) { /* … */ }
+2870: try: id_ = id_[0]
__Pyx_TraceLine(2870,0,__PYX_ERR(0, 2870, __pyx_L1_error)) { /*try:*/ { __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_id_, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2870, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_13); __pyx_t_13 = 0; } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L23_try_end; __pyx_L18_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L20_except_error:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9); goto __pyx_L1_error; __pyx_L19_exception_handled:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9); __pyx_L23_try_end:; }
+2871: except : warnings.warn("The station id is given as a non iterable "
__Pyx_TraceLine(2871,0,__PYX_ERR(0, 2871, __pyx_L20_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.station_id", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 2871, __pyx_L20_except_error) __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2871, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2871, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_12))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_u_The_station_id_is_given_as_a_non}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2871, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L19_exception_handled; }
2872: "object, but can keep the same format in return.")
+2873: if id_==-1: id_= 0 if how=='py' else id_ + 2
__Pyx_TraceLine(2873,0,__PYX_ERR(0, 2873, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_id_, __pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2873, __pyx_L1_error) if (__pyx_t_6) { __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_how, __pyx_n_u_py, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 2873, __pyx_L1_error) if (__pyx_t_6) { __Pyx_INCREF(__pyx_int_0); __pyx_t_3 = __pyx_int_0; } else { __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_v_id_, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2873, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_id_, __pyx_t_3); __pyx_t_3 = 0; }
2874:
+2875: return id_
__Pyx_TraceLine(2875,0,__PYX_ERR(0, 2875, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_id_); __pyx_r = __pyx_v_id_; goto __pyx_L0;
2876:
+2877: def assert_doi(doi):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_108assert_doi(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_107assert_doi, "\n assert the depth of investigation Depth of investigation converter \n\n :param doi: depth of investigation in meters. If value is given as string \n following by yhe index suffix of kilometers 'km', value should be \n converted instead. \n :type doi: str|float \n \n :returns doi:value in meter\n :rtype: float\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_108assert_doi = {"assert_doi", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_108assert_doi, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_107assert_doi}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_108assert_doi(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_doi = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("assert_doi (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_doi,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_doi)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2877, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "assert_doi") < 0)) __PYX_ERR(0, 2877, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_doi = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("assert_doi", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2877, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.assert_doi", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_107assert_doi(__pyx_self, __pyx_v_doi); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_107assert_doi(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_doi) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__148) __Pyx_TraceCall("assert_doi", __pyx_f[0], 2877, 0, __PYX_ERR(0, 2877, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_doi); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils.assert_doi", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_doi); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__423 = PyTuple_Pack(1, __pyx_n_s_doi); if (unlikely(!__pyx_tuple__423)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__423); __Pyx_GIVEREF(__pyx_tuple__423); /* … */ __Pyx_TraceLine(2877,0,__PYX_ERR(0, 2877, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_108assert_doi, 0, __pyx_n_s_assert_doi, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__148)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_assert_doi, __pyx_t_2) < 0) __PYX_ERR(0, 2877, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__148 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__423, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_assert_doi, 2877, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__148)) __PYX_ERR(0, 2877, __pyx_L1_error)
2878: """
2879: assert the depth of investigation Depth of investigation converter
2880:
2881: :param doi: depth of investigation in meters. If value is given as string
2882: following by yhe index suffix of kilometers 'km', value should be
2883: converted instead.
2884: :type doi: str|float
2885:
2886: :returns doi:value in meter
2887: :rtype: float
2888:
2889: """
+2890: if isinstance (doi, str):
__Pyx_TraceLine(2890,0,__PYX_ERR(0, 2890, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_doi); if (__pyx_t_1) { /* … */ }
+2891: if doi.find('km')>=0 :
__Pyx_TraceLine(2891,0,__PYX_ERR(0, 2891, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_doi, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_n_u_km}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2891, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 2891, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+2892: try: doi= float(doi.replace('km', '000'))
__Pyx_TraceLine(2892,0,__PYX_ERR(0, 2892, __pyx_L1_error)) { /*try:*/ { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_doi, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2892, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__149, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2892, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyNumber_Float(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2892, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_doi, __pyx_t_3); __pyx_t_3 = 0; } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L10_try_end:; } /* … */ __pyx_tuple__149 = PyTuple_Pack(2, __pyx_n_u_km, __pyx_kp_u_000); if (unlikely(!__pyx_tuple__149)) __PYX_ERR(0, 2892, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__149); __Pyx_GIVEREF(__pyx_tuple__149);
+2893: except :TypeError (" Unrecognized value. Expect value in 'km' "
__Pyx_TraceLine(2893,0,__PYX_ERR(0, 2893, __pyx_L7_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.assert_doi", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 2893, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_4); /* … */ __Pyx_TraceLine(2893,0,__PYX_ERR(0, 2893, __pyx_L7_except_error)) __pyx_t_10 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Unrecognized_value_Expect_value, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2893, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2893, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L6_exception_handled; }
+2894: f"or 'm' not: {doi!r}")
__Pyx_TraceLine(2894,0,__PYX_ERR(0, 2894, __pyx_L7_except_error)) __pyx_t_9 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_doi), __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2894, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9);
+2895: try: doi = float(doi)
__Pyx_TraceLine(2895,0,__PYX_ERR(0, 2895, __pyx_L1_error)) { /*try:*/ { __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_v_doi); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2895, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_doi, __pyx_t_4); __pyx_t_4 = 0; } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L18_try_end; __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L15_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L1_error; __pyx_L14_exception_handled:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); __pyx_L18_try_end:; }
+2896: except: TypeError ("Depth of investigation must be a float number "
__Pyx_TraceLine(2896,0,__PYX_ERR(0, 2896, __pyx_L15_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.assert_doi", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 2896, __pyx_L15_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__150, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2896, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L14_exception_handled; } /* … */ __pyx_tuple__150 = PyTuple_Pack(1, __pyx_kp_u_Depth_of_investigation_must_be_a); if (unlikely(!__pyx_tuple__150)) __PYX_ERR(0, 2896, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__150); __Pyx_GIVEREF(__pyx_tuple__150);
2897: "not: {str(type(doi).__name__!r)}")
+2898: return doi
__Pyx_TraceLine(2898,0,__PYX_ERR(0, 2898, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_doi); __pyx_r = __pyx_v_doi; goto __pyx_L0;
2899:
+2900: def strip_item(item_to_clean, item=None, multi_space=12):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_110strip_item(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_109strip_item, "\n Function to strip item around string values. if the item to clean is None or \n item-to clean is \"''\", function will return None value\n\n Parameters\n ----------\n * item_to_clean : list or np.ndarray of string \n List to strip item.\n * cleaner : str , optional\n item to clean , it may change according the use. The default is ''.\n * multi_space : int, optional\n degree of repetition may find around the item. The default is 12.\n Returns\n -------\n list or ndarray\n item_to_clean , cleaned item \n \n :Example: \n \n >>> import numpy as np\n >>> new_data=_strip_item (item_to_clean=np.array([' ss_data',' pati ']))\n >>> print(np.array([' ss_data',' pati ']))\n ... print(new_data)\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_110strip_item = {"strip_item", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_110strip_item, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_109strip_item}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_110strip_item(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_item_to_clean = 0; PyObject *__pyx_v_item = 0; PyObject *__pyx_v_multi_space = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("strip_item (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_item_to_clean,&__pyx_n_s_item,&__pyx_n_s_multi_space,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_12))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_item_to_clean)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2900, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_item); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2900, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_multi_space); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2900, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "strip_item") < 0)) __PYX_ERR(0, 2900, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_item_to_clean = values[0]; __pyx_v_item = values[1]; __pyx_v_multi_space = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("strip_item", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 2900, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.strip_item", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_109strip_item(__pyx_self, __pyx_v_item_to_clean, __pyx_v_item, __pyx_v_multi_space); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_109strip_item(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_item_to_clean, PyObject *__pyx_v_item, PyObject *__pyx_v_multi_space) { PyObject *__pyx_v_cleaner = NULL; PyObject *__pyx_v_jj = NULL; PyObject *__pyx_v_ss = NULL; PyObject *__pyx_v_space = NULL; PyObject *__pyx_v_new_ss = NULL; PyObject *__pyx_9genexpr34__pyx_v_ii = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__151) __Pyx_TraceCall("strip_item", __pyx_f[0], 2900, 0, __PYX_ERR(0, 2900, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_item_to_clean); __Pyx_INCREF(__pyx_v_item); __Pyx_INCREF(__pyx_v_multi_space); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils.strip_item", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cleaner); __Pyx_XDECREF(__pyx_v_jj); __Pyx_XDECREF(__pyx_v_ss); __Pyx_XDECREF(__pyx_v_space); __Pyx_XDECREF(__pyx_v_new_ss); __Pyx_XDECREF(__pyx_9genexpr34__pyx_v_ii); __Pyx_XDECREF(__pyx_v_item_to_clean); __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_multi_space); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__424 = PyTuple_Pack(9, __pyx_n_s_item_to_clean, __pyx_n_s_item, __pyx_n_s_multi_space, __pyx_n_s_cleaner, __pyx_n_s_jj, __pyx_n_s_ss, __pyx_n_s_space, __pyx_n_s_new_ss, __pyx_n_s_ii); if (unlikely(!__pyx_tuple__424)) __PYX_ERR(0, 2900, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__424); __Pyx_GIVEREF(__pyx_tuple__424); __pyx_codeobj__151 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__424, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_strip_item, 2900, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__151)) __PYX_ERR(0, 2900, __pyx_L1_error) /* … */ __Pyx_TraceLine(2900,0,__PYX_ERR(0, 2900, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_110strip_item, 0, __pyx_n_s_strip_item, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__151)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__425); if (PyDict_SetItem(__pyx_d, __pyx_n_s_strip_item, __pyx_t_2) < 0) __PYX_ERR(0, 2900, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__425 = PyTuple_Pack(2, Py_None, ((PyObject *)__pyx_int_12)); if (unlikely(!__pyx_tuple__425)) __PYX_ERR(0, 2900, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__425); __Pyx_GIVEREF(__pyx_tuple__425);
2901: """
2902: Function to strip item around string values. if the item to clean is None or
2903: item-to clean is "''", function will return None value
2904:
2905: Parameters
2906: ----------
2907: * item_to_clean : list or np.ndarray of string
2908: List to strip item.
2909: * cleaner : str , optional
2910: item to clean , it may change according the use. The default is ''.
2911: * multi_space : int, optional
2912: degree of repetition may find around the item. The default is 12.
2913: Returns
2914: -------
2915: list or ndarray
2916: item_to_clean , cleaned item
2917:
2918: :Example:
2919:
2920: >>> import numpy as np
2921: >>> new_data=_strip_item (item_to_clean=np.array([' ss_data',' pati ']))
2922: >>> print(np.array([' ss_data',' pati ']))
2923: ... print(new_data)
2924:
2925: """
+2926: if item==None :
__Pyx_TraceLine(2926,0,__PYX_ERR(0, 2926, __pyx_L1_error)) __pyx_t_1 = PyObject_RichCompare(__pyx_v_item, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2926, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2926, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+2927: item = ' '
__Pyx_TraceLine(2927,0,__PYX_ERR(0, 2927, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__14); __Pyx_DECREF_SET(__pyx_v_item, __pyx_kp_u__14);
2928:
+2929: cleaner =[(''+ ii*'{0}'.format(item)) for ii in range(multi_space)]
__Pyx_TraceLine(2929,0,__PYX_ERR(0, 2929, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_multi_space); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2929, __pyx_L6_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2929, __pyx_L6_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2929, __pyx_L6_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2929, __pyx_L6_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2929, __pyx_L6_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2929, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_9genexpr34__pyx_v_ii, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_0_2, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_item}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyNumber_Multiply(__pyx_9genexpr34__pyx_v_ii, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_kp_u__22, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 2929, __pyx_L6_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_9genexpr34__pyx_v_ii); __pyx_9genexpr34__pyx_v_ii = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr34__pyx_v_ii); __pyx_9genexpr34__pyx_v_ii = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __pyx_v_cleaner = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
2930:
+2931: if isinstance (item_to_clean, str) :
__Pyx_TraceLine(2931,0,__PYX_ERR(0, 2931, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Check(__pyx_v_item_to_clean); if (__pyx_t_2) { /* … */ }
+2932: item_to_clean=[item_to_clean]
__Pyx_TraceLine(2932,0,__PYX_ERR(0, 2932, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2932, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_item_to_clean); __Pyx_GIVEREF(__pyx_v_item_to_clean); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_item_to_clean)) __PYX_ERR(0, 2932, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_item_to_clean, __pyx_t_1); __pyx_t_1 = 0;
2933:
2934: # if type(item_to_clean ) != list :#or type(item_to_clean ) !=np.ndarray:
2935: # if type(item_to_clean ) !=np.ndarray:
2936: # item_to_clean=[item_to_clean]
+2937: if item_to_clean in cleaner or item_to_clean ==['']:
__Pyx_TraceLine(2937,0,__PYX_ERR(0, 2937, __pyx_L1_error)) __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_item_to_clean, __pyx_v_cleaner, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2937, __pyx_L1_error) if (!__pyx_t_10) { } else { __pyx_t_2 = __pyx_t_10; goto __pyx_L13_bool_binop_done; } __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_u__22); __Pyx_GIVEREF(__pyx_kp_u__22); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__22)) __PYX_ERR(0, 2937, __pyx_L1_error); __pyx_t_4 = PyObject_RichCompare(__pyx_v_item_to_clean, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2937, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2937, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __pyx_t_10; __pyx_L13_bool_binop_done:; if (__pyx_t_2) { /* … */ }
2938: #warnings.warn ('No data found for sanitization; returns None.')
+2939: return None
__Pyx_TraceLine(2939,0,__PYX_ERR(0, 2939, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+2940: try :
__Pyx_TraceLine(2940,0,__PYX_ERR(0, 2940, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L20_try_end; __pyx_L15_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L17_except_error:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L1_error; __pyx_L20_try_end:; }
+2941: multi_space=int(multi_space)
__Pyx_TraceLine(2941,0,__PYX_ERR(0, 2941, __pyx_L15_error)) __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_multi_space); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2941, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_multi_space, __pyx_t_4); __pyx_t_4 = 0;
+2942: except :
__Pyx_TraceLine(2942,0,__PYX_ERR(0, 2942, __pyx_L17_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.strip_item", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 2942, __pyx_L17_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3);
+2943: raise TypeError('argument <multplier> must be an integer'
__Pyx_TraceLine(2943,0,__PYX_ERR(0, 2943, __pyx_L17_except_error)) __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2943, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_8, 0, 0, 0); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __PYX_ERR(0, 2943, __pyx_L17_except_error) }
+2944: 'not {0}'.format(type(multi_space)))
__Pyx_TraceLine(2944,0,__PYX_ERR(0, 2944, __pyx_L17_except_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_argument_multplier_must_be_an_in, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2944, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_14 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, ((PyObject *)Py_TYPE(__pyx_v_multi_space))}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2944, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; }
2945:
+2946: for jj, ss in enumerate(item_to_clean) :
__Pyx_TraceLine(2946,0,__PYX_ERR(0, 2946, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_3 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_item_to_clean)) || PyTuple_CheckExact(__pyx_v_item_to_clean)) { __pyx_t_1 = __pyx_v_item_to_clean; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_item_to_clean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2946, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2946, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2946, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2946, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 2946, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_6(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 2946, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_ss, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_jj, __pyx_t_3); __pyx_t_4 = __Pyx_PyInt_AddObjC(__pyx_t_3, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2946, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_4; __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(2946,0,__PYX_ERR(0, 2946, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+2947: for space in cleaner:
__Pyx_TraceLine(2947,0,__PYX_ERR(0, 2947, __pyx_L1_error)) __pyx_t_4 = __pyx_v_cleaner; __Pyx_INCREF(__pyx_t_4); __pyx_t_15 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2947, __pyx_L1_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_15); __Pyx_INCREF(__pyx_t_8); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 2947, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2947, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_XDECREF_SET(__pyx_v_space, __pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(2947,0,__PYX_ERR(0, 2947, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+2948: if space in ss :
__Pyx_TraceLine(2948,0,__PYX_ERR(0, 2948, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_space, __pyx_v_ss, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 2948, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+2949: new_ss=ss.strip(space)
__Pyx_TraceLine(2949,0,__PYX_ERR(0, 2949, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_ss, __pyx_n_s_strip); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2949, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_14 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_v_space}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2949, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_new_ss, __pyx_t_8); __pyx_t_8 = 0;
+2950: item_to_clean[jj]=new_ss
__Pyx_TraceLine(2950,0,__PYX_ERR(0, 2950, __pyx_L1_error)) if (unlikely((PyObject_SetItem(__pyx_v_item_to_clean, __pyx_v_jj, __pyx_v_new_ss) < 0))) __PYX_ERR(0, 2950, __pyx_L1_error)
2951:
+2952: return item_to_clean
__Pyx_TraceLine(2952,0,__PYX_ERR(0, 2952, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_item_to_clean); __pyx_r = __pyx_v_item_to_clean; goto __pyx_L0;
2953:
+2954: def parse_json(json_fn =None,
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_318__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 2954, 0, __PYX_ERR(0, 2954, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(2957,0,__PYX_ERR(0, 2957, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2954, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None)) __PYX_ERR(0, 2954, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None)) __PYX_ERR(0, 2954, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_n_u_load));
__Pyx_GIVEREF(((PyObject*)__pyx_n_u_load));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject*)__pyx_n_u_load))) __PYX_ERR(0, 2954, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, Py_None)) __PYX_ERR(0, 2954, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_verbose);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_verbose);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self)->__pyx_arg_verbose)) __PYX_ERR(0, 2954, __pyx_L1_error);
/* … */
__Pyx_TraceLine(2954,0,__PYX_ERR(0, 2954, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2954, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 2954, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 2954, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_112parse_json(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_111parse_json, " Parse Java Script Object Notation file and collect data from JSON\n config file. \n \n :param json_fn: Json filename, URL or output JSON name if `data` is \n given and `todo` is set to ``dump``.Otherwise the JSON output filename \n should be the `data` or the given variable name.\n :param data: Data in Python obj to serialize. \n :param todo: Action to perform with JSON: \n - load: Load data from the JSON file \n - dump: serialize data from the Python object and create a JSON file\n :param savepath: If ``default`` should save the `json_fn` \n If path does not exist, should save to the <'_savejson_'>\n default path .\n :param verbose: int, control the verbosity. Output messages\n \n .. see also:: Read more about JSON doc\n https://docs.python.org/3/library/json.html\n or https://www.w3schools.com/python/python_json.asp \n or https://www.geeksforgeeks.org/json-load-in-python/\n ...\n \n :Example: \n >>> PATH = 'data/model'\n >>> k_ =['model', 'iter', 'mesh', 'data']\n >>> try : \n INVERS_KWS = {\n s +'_fn':os.path.join(PATH, file) \n for file in os.listdir(PATH) \n for s in k_ if file.lower().find(s)>=0\n }\n except :\n INVERS=dict()\n >>> TRES=[10, 66, 70, 100, 1000, 3000]# 7000] \n >>> LNS =['river water','fracture zone', 'MWG', 'LWG', \n 'granite', 'igneous rocks', 'basement rocks']\n >>> import gofast.tools.coreutils as FU\n >>> geo_kws ={'oc2d': INVERS_KWS, \n 'TRES':TRES, 'LN':LNS}\n # serialize json data and save to 'jsontest.json' file\n >>> FU.parse_json(json_fn = 'jsontest.json', \n data=geo_kws, todo='dump', indent=3,\n savepath ='data/saveJSON', sort_keys=True)\n # Load data from 'json""test.json' file.\n >>> FU.parse_json(json_fn='data/saveJSON/jsontest.json', todo ='load')\n \n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_112parse_json = {"parse_json", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_112parse_json, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_111parse_json};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_112parse_json(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_json_fn = 0;
PyObject *__pyx_v_data = 0;
PyObject *__pyx_v_todo = 0;
PyObject *__pyx_v_savepath = 0;
PyObject *__pyx_v_verbose = 0;
PyObject *__pyx_v_jsonkws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("parse_json (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_jsonkws = PyDict_New(); if (unlikely(!__pyx_v_jsonkws)) return NULL;
__Pyx_GOTREF(__pyx_v_jsonkws);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_json_fn,&__pyx_n_s_data,&__pyx_n_s_todo,&__pyx_n_s_savepath,&__pyx_n_s_verbose,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults6 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_self);
values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_jsonkws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_111parse_json(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_json_fn, PyObject *__pyx_v_data, PyObject *__pyx_v_todo, PyObject *__pyx_v_savepath, PyObject *__pyx_v_verbose, PyObject *__pyx_v_jsonkws) {
PyObject *__pyx_v_domsg = NULL;
PyObject *__pyx_v_JSON = NULL;
PyObject *__pyx_v_fj = NULL;
PyObject *__pyx_v_fw = NULL;
PyObject *__pyx_v_msg = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__152)
__Pyx_TraceCall("parse_json", __pyx_f[0], 2954, 0, __PYX_ERR(0, 2954, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_json_fn);
__Pyx_INCREF(__pyx_v_data);
__Pyx_INCREF(__pyx_v_todo);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_XDECREF(__pyx_t_21);
__Pyx_XDECREF(__pyx_t_22);
__Pyx_AddTraceback("gofast.tools.coreutils.parse_json", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_domsg);
__Pyx_XDECREF(__pyx_v_JSON);
__Pyx_XDECREF(__pyx_v_fj);
__Pyx_XDECREF(__pyx_v_fw);
__Pyx_XDECREF(__pyx_v_msg);
__Pyx_XDECREF(__pyx_v_json_fn);
__Pyx_XDECREF(__pyx_v_data);
__Pyx_XDECREF(__pyx_v_todo);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__426 = PyTuple_Pack(11, __pyx_n_s_json_fn, __pyx_n_s_data, __pyx_n_s_todo, __pyx_n_s_savepath, __pyx_n_s_verbose, __pyx_n_s_jsonkws, __pyx_n_s_domsg, __pyx_n_s_JSON_2, __pyx_n_s_fj, __pyx_n_s_fw, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__426)) __PYX_ERR(0, 2954, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__426);
__Pyx_GIVEREF(__pyx_tuple__426);
/* … */
__Pyx_TraceLine(2954,0,__PYX_ERR(0, 2954, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2954, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_verbose, __pyx_n_s_int) < 0) __PYX_ERR(0, 2954, __pyx_L1_error)
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_112parse_json, 0, __pyx_n_s_parse_json, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__152)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2954, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults6), 1)) __PYX_ERR(0, 2954, __pyx_L1_error)
__pyx_codeobj__152 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__426, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parse_json, 2954, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__152)) __PYX_ERR(0, 2954, __pyx_L1_error)
+2955: data=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_load)));
2956: todo='load',
+2957: savepath=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_verbose); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_json_fn); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2954, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2954, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2954, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2954, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 2954, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_jsonkws, values + 0, kwd_pos_args, "parse_json") < 0)) __PYX_ERR(0, 2954, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_json_fn = values[0]; __pyx_v_data = values[1]; __pyx_v_todo = values[2]; __pyx_v_savepath = values[3]; __pyx_v_verbose = ((PyObject*)values[4]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parse_json", 0, 0, 5, __pyx_nargs); __PYX_ERR(0, 2954, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_jsonkws); __pyx_v_jsonkws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.parse_json", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_verbose), (&PyInt_Type), 0, "verbose", 1))) __PYX_ERR(0, 2958, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_111parse_json(__pyx_self, __pyx_v_json_fn, __pyx_v_data, __pyx_v_todo, __pyx_v_savepath, __pyx_v_verbose, __pyx_v_jsonkws);
+2958: verbose:int =0,
__Pyx_TraceLine(2958,0,__PYX_ERR(0, 2958, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_0)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_0))) __PYX_ERR(0, 2958, __pyx_L1_error) __Pyx_INCREF(__pyx_int_0); __Pyx_CyFunction_Defaults(__pyx_defaults6, __pyx_t_4)->__pyx_arg_verbose = ((PyObject*)__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_6gofast_5tools_9coreutils_318__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_json, __pyx_t_4) < 0) __PYX_ERR(0, 2954, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2959: **jsonkws):
2960: """ Parse Java Script Object Notation file and collect data from JSON
2961: config file.
2962:
2963: :param json_fn: Json filename, URL or output JSON name if `data` is
2964: given and `todo` is set to ``dump``.Otherwise the JSON output filename
2965: should be the `data` or the given variable name.
2966: :param data: Data in Python obj to serialize.
2967: :param todo: Action to perform with JSON:
2968: - load: Load data from the JSON file
2969: - dump: serialize data from the Python object and create a JSON file
2970: :param savepath: If ``default`` should save the `json_fn`
2971: If path does not exist, should save to the <'_savejson_'>
2972: default path .
2973: :param verbose: int, control the verbosity. Output messages
2974:
2975: .. see also:: Read more about JSON doc
2976: https://docs.python.org/3/library/json.html
2977: or https://www.w3schools.com/python/python_json.asp
2978: or https://www.geeksforgeeks.org/json-load-in-python/
2979: ...
2980:
2981: :Example:
2982: >>> PATH = 'data/model'
2983: >>> k_ =['model', 'iter', 'mesh', 'data']
2984: >>> try :
2985: INVERS_KWS = {
2986: s +'_fn':os.path.join(PATH, file)
2987: for file in os.listdir(PATH)
2988: for s in k_ if file.lower().find(s)>=0
2989: }
2990: except :
2991: INVERS=dict()
2992: >>> TRES=[10, 66, 70, 100, 1000, 3000]# 7000]
2993: >>> LNS =['river water','fracture zone', 'MWG', 'LWG',
2994: 'granite', 'igneous rocks', 'basement rocks']
2995: >>> import gofast.tools.coreutils as FU
2996: >>> geo_kws ={'oc2d': INVERS_KWS,
2997: 'TRES':TRES, 'LN':LNS}
2998: # serialize json data and save to 'jsontest.json' file
2999: >>> FU.parse_json(json_fn = 'jsontest.json',
3000: data=geo_kws, todo='dump', indent=3,
3001: savepath ='data/saveJSON', sort_keys=True)
3002: # Load data from 'jsontest.json' file.
3003: >>> FU.parse_json(json_fn='data/saveJSON/jsontest.json', todo ='load')
3004:
3005: """
+3006: todo, domsg =return_ctask(todo)
__Pyx_TraceLine(3006,0,__PYX_ERR(0, 3006, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_return_ctask); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_todo}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3006, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 3006, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3006, __pyx_L1_error) __pyx_L4_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_2); __pyx_t_2 = 0; __pyx_v_domsg = __pyx_t_3; __pyx_t_3 = 0;
3007: # read urls by default json_fn can hold a url
+3008: try :
__Pyx_TraceLine(3008,0,__PYX_ERR(0, 3008, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_L10_try_end:; }
+3009: if json_fn.find('http') >=0 :
__Pyx_TraceLine(3009,0,__PYX_ERR(0, 3009, __pyx_L5_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_json_fn, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3009, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_http}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3009, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3009, __pyx_L5_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3009, __pyx_L5_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_10) { /* … */ }
+3010: todo, json_fn, data = fetch_json_data_from_url(json_fn, todo)
__Pyx_TraceLine(3010,0,__PYX_ERR(0, 3010, __pyx_L5_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_fetch_json_data_from_url); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3010, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_json_fn, __pyx_v_todo}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3010, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3010, __pyx_L5_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); __pyx_t_5 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3010, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3010, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3010, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3010, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); index = 0; __pyx_t_1 = __pyx_t_6(__pyx_t_11); if (unlikely(!__pyx_t_1)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_11); if (unlikely(!__pyx_t_2)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 2; __pyx_t_5 = __pyx_t_6(__pyx_t_11); if (unlikely(!__pyx_t_5)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_11), 3) < 0) __PYX_ERR(0, 3010, __pyx_L5_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L13_unpacking_done; __pyx_L12_unpacking_failed:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3010, __pyx_L5_error) __pyx_L13_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_json_fn, __pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_5); __pyx_t_5 = 0;
+3011: except:
__Pyx_TraceLine(3011,0,__PYX_ERR(0, 3011, __pyx_L7_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L6_exception_handled; }
3012: #'NoneType' object has no attribute 'find' if data is not given
3013: pass
3014:
+3015: if todo.find('dump')>=0:
__Pyx_TraceLine(3015,0,__PYX_ERR(0, 3015, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_dump}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3015, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3015, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3015, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_10) { /* … */ }
+3016: json_fn = get_config_fname_from_varname(
__Pyx_TraceLine(3016,0,__PYX_ERR(0, 3016, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_get_config_fname_from_varname); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3016, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(3017,0,__PYX_ERR(0, 3017, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3016, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data)) __PYX_ERR(0, 3016, __pyx_L1_error); /* … */ __Pyx_TraceLine(3016,0,__PYX_ERR(0, 3016, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3016, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_json_fn, __pyx_t_1); __pyx_t_1 = 0;
+3017: data, config_fname= json_fn, config='.json')
__pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3017, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_config_fname, __pyx_v_json_fn) < 0) __PYX_ERR(0, 3017, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_config, __pyx_kp_u_json) < 0) __PYX_ERR(0, 3017, __pyx_L1_error)
3018:
+3019: JSON = dict(load=json.load,# use loads rather than load
__Pyx_TraceLine(3019,0,__PYX_ERR(0, 3019, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_json_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_load); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_load, __pyx_t_3) < 0) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+3020: loads=json.loads,
__Pyx_TraceLine(3020,0,__PYX_ERR(0, 3020, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_json_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3020, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_loads); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3020, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_loads, __pyx_t_2) < 0) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+3021: dump= json.dump,
__Pyx_TraceLine(3021,0,__PYX_ERR(0, 3021, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_json_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3021, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dump); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3021, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dump, __pyx_t_3) < 0) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+3022: dumps= json.dumps)
__Pyx_TraceLine(3022,0,__PYX_ERR(0, 3022, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_json_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_dumps); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3022, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dumps, __pyx_t_2) < 0) __PYX_ERR(0, 3019, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_JSON = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+3023: try :
__Pyx_TraceLine(3023,0,__PYX_ERR(0, 3023, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L20_try_end; __pyx_L15_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L17_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_8, __pyx_t_7); goto __pyx_L1_error; __pyx_L20_try_end:; }
+3024: if todo=='load': # read JSON files
__Pyx_TraceLine(3024,0,__PYX_ERR(0, 3024, __pyx_L15_error)) __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_load, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3024, __pyx_L15_error) if (__pyx_t_10) { /* … */ goto __pyx_L21; }
+3025: with open(json_fn) as fj:
__Pyx_TraceLine(3025,0,__PYX_ERR(0, 3025, __pyx_L15_error)) /*with:*/ { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_open, __pyx_v_json_fn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3025, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3025, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3025, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3025, __pyx_L22_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_fj = __pyx_t_3; __pyx_t_3 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L31_try_end; __pyx_L26_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_json", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 3025, __pyx_L28_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3025, __pyx_L28_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_5, NULL); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3025, __pyx_L28_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_16); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_10 < 0) __PYX_ERR(0, 3025, __pyx_L28_except_error) __pyx_t_17 = (!__pyx_t_10); if (unlikely(__pyx_t_17)) { __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_1, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 3025, __pyx_L28_except_error) } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L27_exception_handled; } __pyx_L28_except_error:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L15_error; __pyx_L27_exception_handled:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_L31_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_12) { __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3025, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } goto __pyx_L25; } __pyx_L25:; } goto __pyx_L35; __pyx_L22_error:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L15_error; __pyx_L35:; }
+3026: data = JSON[todo](fj)
__Pyx_TraceLine(3026,0,__PYX_ERR(0, 3026, __pyx_L26_error)) __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_JSON, __pyx_v_todo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3026, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_fj}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3026, __pyx_L26_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
+3027: elif todo=='loads': # can be JSON string format
__Pyx_TraceLine(3027,0,__PYX_ERR(0, 3027, __pyx_L15_error)) __pyx_t_17 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_loads, Py_EQ)); if (unlikely((__pyx_t_17 < 0))) __PYX_ERR(0, 3027, __pyx_L15_error) if (__pyx_t_17) { /* … */ goto __pyx_L21; }
+3028: data = JSON[todo](json_fn)
__Pyx_TraceLine(3028,0,__PYX_ERR(0, 3028, __pyx_L15_error)) __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_JSON, __pyx_v_todo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3028, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_json_fn}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3028, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
+3029: elif todo =='dump': # store data in JSON file.
__Pyx_TraceLine(3029,0,__PYX_ERR(0, 3029, __pyx_L15_error)) __pyx_t_17 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dump, Py_EQ)); if (unlikely((__pyx_t_17 < 0))) __PYX_ERR(0, 3029, __pyx_L15_error) if (__pyx_t_17) { /* … */ goto __pyx_L21; }
+3030: with open(f'{json_fn}.json', 'w') as fw:
__Pyx_TraceLine(3030,0,__PYX_ERR(0, 3030, __pyx_L15_error)) /*with:*/ { __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_json_fn, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3030, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_json); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3030, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3030, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 3030, __pyx_L15_error); __Pyx_INCREF(__pyx_n_u_w); __Pyx_GIVEREF(__pyx_n_u_w); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_w)) __PYX_ERR(0, 3030, __pyx_L15_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3030, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3030, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3030, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3030, __pyx_L36_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_fw = __pyx_t_3; __pyx_t_3 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L45_try_end; __pyx_L40_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_json", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 3030, __pyx_L42_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3030, __pyx_L42_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3030, __pyx_L42_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_16); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_17 < 0) __PYX_ERR(0, 3030, __pyx_L42_except_error) __pyx_t_10 = (!__pyx_t_17); if (unlikely(__pyx_t_10)) { __Pyx_GIVEREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_2, __pyx_t_1); __pyx_t_5 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __PYX_ERR(0, 3030, __pyx_L42_except_error) } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L41_exception_handled; } __pyx_L42_except_error:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_14, __pyx_t_13); goto __pyx_L15_error; __pyx_L41_exception_handled:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_14, __pyx_t_13); __pyx_L45_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_12) { __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3030, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } goto __pyx_L39; } __pyx_L39:; } goto __pyx_L49; __pyx_L36_error:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L15_error; __pyx_L49:; }
+3031: data = JSON[todo](data, fw, **jsonkws)
__Pyx_TraceLine(3031,0,__PYX_ERR(0, 3031, __pyx_L40_error)) __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_JSON, __pyx_v_todo); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3031, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3031, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data)) __PYX_ERR(0, 3031, __pyx_L40_error); __Pyx_INCREF(__pyx_v_fw); __Pyx_GIVEREF(__pyx_v_fw); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_fw)) __PYX_ERR(0, 3031, __pyx_L40_error); __pyx_t_2 = PyDict_Copy(__pyx_v_jsonkws); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3031, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3031, __pyx_L40_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_5); __pyx_t_5 = 0;
+3032: elif todo=='dumps': # store data in JSON format not output file.
__Pyx_TraceLine(3032,0,__PYX_ERR(0, 3032, __pyx_L15_error)) __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dumps, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3032, __pyx_L15_error) if (__pyx_t_10) { /* … */ } __pyx_L21:;
+3033: data = JSON[todo](data, **jsonkws)
__Pyx_TraceLine(3033,0,__PYX_ERR(0, 3033, __pyx_L15_error)) __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_JSON, __pyx_v_todo); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3033, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3033, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data)) __PYX_ERR(0, 3033, __pyx_L15_error); __pyx_t_5 = PyDict_Copy(__pyx_v_jsonkws); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3033, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3033, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_3); __pyx_t_3 = 0;
3034:
+3035: except json.JSONDecodeError:
__Pyx_TraceLine(3035,0,__PYX_ERR(0, 3035, __pyx_L17_except_error)) __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_5, &__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_json_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3035, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_JSONDecodeError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3035, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_11); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_ErrRestore(__pyx_t_3, __pyx_t_5, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_2 = 0; if (__pyx_t_4) { __Pyx_AddTraceback("gofast.tools.coreutils.parse_json", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_5, &__pyx_t_3) < 0) __PYX_ERR(0, 3035, __pyx_L17_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_3);
+3036: raise json.JSONDecodeError(f"Unable {domsg} JSON {json_fn!r} file. "
__Pyx_TraceLine(3036,0,__PYX_ERR(0, 3036, __pyx_L17_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_json_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_JSONDecodeError); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_19 = 0; __pyx_t_20 = 127; __Pyx_INCREF(__pyx_kp_u_Unable); __pyx_t_19 += 7; __Pyx_GIVEREF(__pyx_kp_u_Unable); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Unable); __pyx_t_21 = __Pyx_PyObject_FormatSimple(__pyx_v_domsg, __pyx_empty_unicode); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u_JSON); __pyx_t_19 += 6; __Pyx_GIVEREF(__pyx_kp_u_JSON); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_JSON); __pyx_t_21 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_json_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u_file_Please_check_your_file); __pyx_t_19 += 30; __Pyx_GIVEREF(__pyx_kp_u_file_Please_check_your_file); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_file_Please_check_your_file); __pyx_t_21 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_19, __pyx_t_20); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+3037: "Please check your file.", f'{json_fn!r}', 1)
__Pyx_TraceLine(3037,0,__PYX_ERR(0, 3037, __pyx_L17_except_error)) __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_json_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3037, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_22 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_22)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_22); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_22, __pyx_t_21, __pyx_t_1, __pyx_int_1}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3036, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 3036, __pyx_L17_except_error) }
+3038: except:
__Pyx_TraceLine(3038,0,__PYX_ERR(0, 3038, __pyx_L17_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_json", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 3038, __pyx_L17_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2);
+3039: msg =''.join([
__Pyx_TraceLine(3039,0,__PYX_ERR(0, 3039, __pyx_L17_except_error)) __pyx_t_11 = PyList_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3039, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_1)) __PYX_ERR(0, 3039, __pyx_L17_except_error); __pyx_t_1 = 0; __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3039, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+3040: f"{'Unrecognizable file' if todo.find('load')>=0 else'Unable to serialize'}"
__Pyx_TraceLine(3040,0,__PYX_ERR(0, 3040, __pyx_L17_except_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3040, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_21 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_21)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_21); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_n_u_load}; __pyx_t_18 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3040, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyObject_RichCompare(__pyx_t_18, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3040, __pyx_L17_except_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3040, __pyx_L17_except_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_10) { __Pyx_INCREF(__pyx_kp_u_Unrecognizable_file); __pyx_t_11 = __pyx_kp_u_Unrecognizable_file; } else { __Pyx_INCREF(__pyx_kp_u_Unable_to_serialize); __pyx_t_11 = __pyx_kp_u_Unable_to_serialize; } __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3040, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
3041: ])
3042:
+3043: raise TypeError(f'{msg} {json_fn!r}. Please check your'
__Pyx_TraceLine(3043,0,__PYX_ERR(0, 3043, __pyx_L17_except_error)) __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3043, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_19 = 0; __pyx_t_20 = 127; __pyx_t_11 = __Pyx_PyUnicode_Unicode(__pyx_v_msg); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3043, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_19 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__14); __pyx_t_11 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_json_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3043, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_kp_u_Please_check_your); __pyx_t_19 += 20; __Pyx_GIVEREF(__pyx_kp_u_Please_check_your); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u_Please_check_your); /* … */ __Pyx_TraceLine(3043,0,__PYX_ERR(0, 3043, __pyx_L17_except_error)) __pyx_t_21 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_19, __pyx_t_20); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3043, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_21); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3043, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 3043, __pyx_L17_except_error) }
+3044: f" {'file' if todo.find('load')>=0 else 'data'}.")
__Pyx_TraceLine(3044,0,__PYX_ERR(0, 3044, __pyx_L17_except_error)) __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3044, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_22 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_21))) { __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_21); if (likely(__pyx_t_22)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21); __Pyx_INCREF(__pyx_t_22); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_21, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_n_u_load}; __pyx_t_18 = __Pyx_PyObject_FastCall(__pyx_t_21, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0; if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3044, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; } __pyx_t_21 = PyObject_RichCompare(__pyx_t_18, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_21); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3044, __pyx_L17_except_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_21); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3044, __pyx_L17_except_error) __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; if (__pyx_t_10) { __Pyx_INCREF(__pyx_n_u_file); __pyx_t_11 = __pyx_n_u_file; } else { __Pyx_INCREF(__pyx_n_u_data); __pyx_t_11 = __pyx_n_u_data; } __pyx_t_21 = __Pyx_PyUnicode_Unicode(__pyx_t_11); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3044, __pyx_L17_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_19 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_kp_u__26);
3045:
+3046: cparser_manager(f'{json_fn}.json',savepath, todo=todo, dpath='_savejson_',
__Pyx_TraceLine(3046,0,__PYX_ERR(0, 3046, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_cparser_manager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_json_fn, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_5, __pyx_kp_u_json); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 3046, __pyx_L1_error); __Pyx_INCREF(__pyx_v_savepath); __Pyx_GIVEREF(__pyx_v_savepath); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_savepath)) __PYX_ERR(0, 3046, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_todo, __pyx_v_todo) < 0) __PYX_ERR(0, 3046, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dpath, __pyx_n_u_savejson) < 0) __PYX_ERR(0, 3046, __pyx_L1_error) /* … */ __Pyx_TraceLine(3046,0,__PYX_ERR(0, 3046, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3046, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+3047: verbose=verbose , config='JSON' )
__Pyx_TraceLine(3047,0,__PYX_ERR(0, 3047, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_verbose, __pyx_v_verbose) < 0) __PYX_ERR(0, 3046, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_config, __pyx_n_u_JSON_2) < 0) __PYX_ERR(0, 3046, __pyx_L1_error)
3048:
+3049: return data
__Pyx_TraceLine(3049,0,__PYX_ERR(0, 3049, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
3050:
+3051: def fetch_json_data_from_url (url:str , todo:str ='load'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_114fetch_json_data_from_url(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_113fetch_json_data_from_url, " Retrieve JSON data from url \n :param url: Universal Resource Locator .\n :param todo: Action to perform with JSON:\n - load: Load data from the JSON file \n - dump: serialize data from the Python object and create a JSON file\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_114fetch_json_data_from_url = {"fetch_json_data_from_url", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_114fetch_json_data_from_url, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_113fetch_json_data_from_url}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_114fetch_json_data_from_url(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_url = 0; PyObject *__pyx_v_todo = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fetch_json_data_from_url (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_url,&__pyx_n_s_todo,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_load))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_url)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3051, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3051, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "fetch_json_data_from_url") < 0)) __PYX_ERR(0, 3051, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_url = ((PyObject*)values[0]); __pyx_v_todo = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fetch_json_data_from_url", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 3051, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.fetch_json_data_from_url", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyUnicode_Type), 0, "url", 1))) __PYX_ERR(0, 3051, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_todo), (&PyUnicode_Type), 0, "todo", 1))) __PYX_ERR(0, 3051, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_113fetch_json_data_from_url(__pyx_self, __pyx_v_url, __pyx_v_todo); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_113fetch_json_data_from_url(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url, PyObject *__pyx_v_todo) { PyObject *__pyx_v_jresponse = NULL; PyObject *__pyx_v_source = NULL; PyObject *__pyx_v_data = NULL; PyObject *__pyx_v_json_fn = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__153) __Pyx_TraceCall("fetch_json_data_from_url", __pyx_f[0], 3051, 0, __PYX_ERR(0, 3051, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_todo); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.fetch_json_data_from_url", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_jresponse); __Pyx_XDECREF(__pyx_v_source); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_json_fn); __Pyx_XDECREF(__pyx_v_todo); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__427 = PyTuple_Pack(6, __pyx_n_s_url, __pyx_n_s_todo, __pyx_n_s_jresponse, __pyx_n_s_source, __pyx_n_s_data, __pyx_n_s_json_fn); if (unlikely(!__pyx_tuple__427)) __PYX_ERR(0, 3051, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__427); __Pyx_GIVEREF(__pyx_tuple__427); __pyx_codeobj__153 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__427, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fetch_json_data_from_url, 3051, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__153)) __PYX_ERR(0, 3051, __pyx_L1_error) /* … */ __Pyx_TraceLine(3051,0,__PYX_ERR(0, 3051, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_url, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3051, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_todo, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3051, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_114fetch_json_data_from_url, 0, __pyx_n_s_fetch_json_data_from_url, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__153)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__428); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_fetch_json_data_from_url, __pyx_t_2) < 0) __PYX_ERR(0, 3051, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__428 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_load)); if (unlikely(!__pyx_tuple__428)) __PYX_ERR(0, 3051, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__428); __Pyx_GIVEREF(__pyx_tuple__428);
3052: """ Retrieve JSON data from url
3053: :param url: Universal Resource Locator .
3054: :param todo: Action to perform with JSON:
3055: - load: Load data from the JSON file
3056: - dump: serialize data from the Python object and create a JSON file
3057: """
+3058: with urllib.request.urlopen(url) as jresponse :
__Pyx_TraceLine(3058,0,__PYX_ERR(0, 3058, __pyx_L1_error)) /*with:*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_urllib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_request); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_urlopen); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_url}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3058, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3058, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_jresponse = __pyx_t_3; __pyx_t_3 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.fetch_json_data_from_url", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 3058, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3058, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3058, __pyx_L9_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_10); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_11 < 0) __PYX_ERR(0, 3058, __pyx_L9_except_error) __pyx_t_12 = (!__pyx_t_11); if (unlikely(__pyx_t_12)) { __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_1, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 3058, __pyx_L9_except_error) } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8_exception_handled; } __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_L12_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_5) { __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3058, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } goto __pyx_L6; } __pyx_L6:; } goto __pyx_L16; __pyx_L3_error:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L1_error; __pyx_L16:; }
+3059: source = jresponse.read()
__Pyx_TraceLine(3059,0,__PYX_ERR(0, 3059, __pyx_L7_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_jresponse, __pyx_n_s_read); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3059, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3059, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_source = __pyx_t_3; __pyx_t_3 = 0;
+3060: data = json.loads(source)
__Pyx_TraceLine(3060,0,__PYX_ERR(0, 3060, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_json_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_loads); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_v_source)) { __Pyx_RaiseUnboundLocalError("source"); __PYX_ERR(0, 3060, __pyx_L1_error) } __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_source}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_data = __pyx_t_2; __pyx_t_2 = 0;
+3061: if todo .find('load')>=0:
__Pyx_TraceLine(3061,0,__PYX_ERR(0, 3061, __pyx_L1_error)) __pyx_t_13 = PyUnicode_Find(__pyx_v_todo, __pyx_n_u_load, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-2))) __PYX_ERR(0, 3061, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3061, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3061, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3061, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_12) { /* … */ }
+3062: todo , json_fn ='loads', source
__Pyx_TraceLine(3062,0,__PYX_ERR(0, 3062, __pyx_L1_error)) __pyx_t_3 = __pyx_n_u_loads; __Pyx_INCREF(__pyx_t_3); if (unlikely(!__pyx_v_source)) { __Pyx_RaiseUnboundLocalError("source"); __PYX_ERR(0, 3062, __pyx_L1_error) } __pyx_t_2 = __pyx_v_source; __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_todo, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_json_fn = __pyx_t_2; __pyx_t_2 = 0;
3063:
+3064: if todo.find('dump')>=0: # then collect the data and dump it
__Pyx_TraceLine(3064,0,__PYX_ERR(0, 3064, __pyx_L1_error)) __pyx_t_13 = PyUnicode_Find(__pyx_v_todo, __pyx_n_u_dump, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-2))) __PYX_ERR(0, 3064, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3064, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3064, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_12) { /* … */ }
3065: # set json default filename
+3066: todo, json_fn = 'dumps', '_urlsourcejsonf.json'
__Pyx_TraceLine(3066,0,__PYX_ERR(0, 3066, __pyx_L1_error)) __pyx_t_3 = __pyx_n_u_dumps; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = __pyx_kp_u_urlsourcejsonf_json; __Pyx_INCREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_todo, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_json_fn, __pyx_t_2); __pyx_t_2 = 0;
3067:
+3068: return todo, json_fn, data
__Pyx_TraceLine(3068,0,__PYX_ERR(0, 3068, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_json_fn)) { __Pyx_RaiseUnboundLocalError("json_fn"); __PYX_ERR(0, 3068, __pyx_L1_error) } __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_todo); __Pyx_GIVEREF(__pyx_v_todo); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_todo)) __PYX_ERR(0, 3068, __pyx_L1_error); __Pyx_INCREF(__pyx_v_json_fn); __Pyx_GIVEREF(__pyx_v_json_fn); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_json_fn)) __PYX_ERR(0, 3068, __pyx_L1_error); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_data)) __PYX_ERR(0, 3068, __pyx_L1_error); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
3069:
+3070: def parse_csv(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_320__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 3070, 0, __PYX_ERR(0, 3070, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(3076,0,__PYX_ERR(0, 3076, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3070, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None)) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None)) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_n_u_reader));
__Pyx_GIVEREF(((PyObject*)__pyx_n_u_reader));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject*)__pyx_n_u_reader))) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, Py_None)) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 4, Py_None)) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)Py_False))) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self)->__pyx_arg_verbose);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self)->__pyx_arg_verbose);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 6, __Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self)->__pyx_arg_verbose)) __PYX_ERR(0, 3070, __pyx_L1_error);
/* … */
__Pyx_TraceLine(3070,0,__PYX_ERR(0, 3070, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3070, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 3070, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 3070, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_116parse_csv(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_115parse_csv, " Parse comma separated file or collect data from CSV.\n \n :param csv_fn: csv filename,or output CSV name if `data` is \n given and `todo` is set to ``write|dictwriter``.Otherwise the CSV \n output filename should be the `c.data` or the given variable name.\n :param data: Sequence Data in Python obj to write. \n :param todo: Action to perform with JSON: \n - reader|DictReader: Load data from the JSON file \n - writer|DictWriter: Write data from the Python object \n and create a CSV file\n :param savepath: If ``default`` should save the `csv_fn` \n If path does not exist, should save to the <'_savecsv_'>\n default path.\n :param fieldnames: is a sequence of keys that identify the order\n in which values in the dictionary passed to the `writerow()`\n method are written `csv_fn` file.\n :param savepath: If ``default`` should save the `csv_fn` \n If path does not exist, should save to the <'_savecsv_'>\n default path .\n :param verbose: int, control the verbosity. Output messages\n :param csvkws: additional keywords csv class arguments \n \n .. see also:: Read more about CSV module in:\n https://docs.python.org/3/library/csv.html or find some examples\n here https://www.programcreek.com/python/example/3190/csv.DictWriter \n or find some FAQS here: \n https://stackoverflow.com/questions/10373247/how-do-i-write-a-python-dictionary-to-a-csv-file\n ...\n :Example:\n >>> import gofast.tools.coreutils as FU\n >>> PATH = 'data/model'\n >>> k_ =['model', 'iter', 'mesh', 'data']\n >>> try : \n INVERS_KWS = {\n s +'_fn':os.path.join(PATH, file) \n for file in os.listdir(PATH) \n for s in k_ if file.lower().find(s)>=0\n }\n except :\n INVERS=dict()\n >>> TRES=[10, 66, 70, 100, 1000, 3000]# 7""000] \n >>> LNS =['river water','fracture zone', 'MWG', 'LWG', \n 'granite', 'igneous rocks', 'basement rocks']\n >>> geo_kws ={'oc2d': INVERS_KWS, \n 'TRES':TRES, 'LN':LNS}\n >>> # write data and save to 'csvtest.csv' file \n >>> # here the `data` is a sequence of dictionary geo_kws\n >>> FU.parse_csv(csv_fn = 'csvtest.csv',data = [geo_kws], \n fieldnames = geo_kws.keys(),todo= 'dictwriter',\n savepath = 'data/saveCSV')\n # collect csv data from the 'csvtest.csv' file \n >>> FU.parse_csv(csv_fn ='data/saveCSV/csvtest.csv',\n todo='dictreader',fieldnames = geo_kws.keys()\n )\n \n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_116parse_csv = {"parse_csv", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_116parse_csv, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_115parse_csv};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_116parse_csv(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_csv_fn = 0;
PyObject *__pyx_v_data = 0;
PyObject *__pyx_v_todo = 0;
PyObject *__pyx_v_fieldnames = 0;
PyObject *__pyx_v_savepath = 0;
PyObject *__pyx_v_header = 0;
PyObject *__pyx_v_verbose = 0;
PyObject *__pyx_v_csvkws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("parse_csv (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_csvkws = PyDict_New(); if (unlikely(!__pyx_v_csvkws)) return NULL;
__Pyx_GOTREF(__pyx_v_csvkws);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_csv_fn,&__pyx_n_s_data,&__pyx_n_s_todo,&__pyx_n_s_fieldnames,&__pyx_n_s_savepath,&__pyx_n_s_header,&__pyx_n_s_verbose,0};
PyObject* values[7] = {0,0,0,0,0,0,0};
__pyx_defaults7 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_self);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_csvkws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_115parse_csv(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csv_fn, PyObject *__pyx_v_data, PyObject *__pyx_v_todo, PyObject *__pyx_v_fieldnames, PyObject *__pyx_v_savepath, PyObject *__pyx_v_header, PyObject *__pyx_v_verbose, PyObject *__pyx_v_csvkws) {
PyObject *__pyx_v_domsg = NULL;
PyObject *__pyx_v_csv_f = NULL;
PyObject *__pyx_v_csv_reader = NULL;
PyObject *__pyx_v_new_csvf = NULL;
PyObject *__pyx_v_csv_writer = NULL;
PyObject *__pyx_v_msg = NULL;
PyObject *__pyx_9genexpr35__pyx_v_row = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__154)
__Pyx_TraceCall("parse_csv", __pyx_f[0], 3070, 0, __PYX_ERR(0, 3070, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_csv_fn);
__Pyx_INCREF(__pyx_v_data);
__Pyx_INCREF(__pyx_v_todo);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_19);
__Pyx_XDECREF(__pyx_t_20);
__Pyx_XDECREF(__pyx_t_22);
__Pyx_XDECREF(__pyx_t_23);
__Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_domsg);
__Pyx_XDECREF(__pyx_v_csv_f);
__Pyx_XDECREF(__pyx_v_csv_reader);
__Pyx_XDECREF(__pyx_v_new_csvf);
__Pyx_XDECREF(__pyx_v_csv_writer);
__Pyx_XDECREF(__pyx_v_msg);
__Pyx_XDECREF(__pyx_9genexpr35__pyx_v_row);
__Pyx_XDECREF(__pyx_v_csv_fn);
__Pyx_XDECREF(__pyx_v_data);
__Pyx_XDECREF(__pyx_v_todo);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__429 = PyTuple_Pack(15, __pyx_n_s_csv_fn, __pyx_n_s_data, __pyx_n_s_todo, __pyx_n_s_fieldnames, __pyx_n_s_savepath, __pyx_n_s_header, __pyx_n_s_verbose, __pyx_n_s_csvkws, __pyx_n_s_domsg, __pyx_n_s_csv_f, __pyx_n_s_csv_reader, __pyx_n_s_new_csvf, __pyx_n_s_csv_writer, __pyx_n_s_msg, __pyx_n_s_row); if (unlikely(!__pyx_tuple__429)) __PYX_ERR(0, 3070, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__429);
__Pyx_GIVEREF(__pyx_tuple__429);
/* … */
__Pyx_TraceLine(3070,0,__PYX_ERR(0, 3070, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3070, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_csv_fn, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3070, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_header, __pyx_n_s_bool) < 0) __PYX_ERR(0, 3070, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_verbose, __pyx_n_s_int) < 0) __PYX_ERR(0, 3070, __pyx_L1_error)
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_116parse_csv, 0, __pyx_n_s_parse_csv, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__154)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3070, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults7), 1)) __PYX_ERR(0, 3070, __pyx_L1_error)
__pyx_codeobj__154 = (PyObject*)__Pyx_PyCode_New(7, 0, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__429, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parse_csv, 3070, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__154)) __PYX_ERR(0, 3070, __pyx_L1_error)
+3071: csv_fn:str =None,
values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+3072: data=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_reader)));
3073: todo='reader',
+3074: fieldnames=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+3075: savepath=None,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_verbose); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_csv_fn); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fieldnames); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_header); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3070, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_csvkws, values + 0, kwd_pos_args, "parse_csv") < 0)) __PYX_ERR(0, 3070, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_csv_fn = ((PyObject*)values[0]); __pyx_v_data = values[1]; __pyx_v_todo = values[2]; __pyx_v_fieldnames = values[3]; __pyx_v_savepath = values[4]; __pyx_v_header = values[5]; __pyx_v_verbose = ((PyObject*)values[6]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parse_csv", 0, 0, 7, __pyx_nargs); __PYX_ERR(0, 3070, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_csvkws); __pyx_v_csvkws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_csv_fn), (&PyUnicode_Type), 1, "csv_fn", 1))) __PYX_ERR(0, 3071, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_verbose), (&PyInt_Type), 0, "verbose", 1))) __PYX_ERR(0, 3077, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_115parse_csv(__pyx_self, __pyx_v_csv_fn, __pyx_v_data, __pyx_v_todo, __pyx_v_fieldnames, __pyx_v_savepath, __pyx_v_header, __pyx_v_verbose, __pyx_v_csvkws);
3076: header: bool=False,
+3077: verbose:int=0,
__Pyx_TraceLine(3077,0,__PYX_ERR(0, 3077, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_0)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_0))) __PYX_ERR(0, 3077, __pyx_L1_error) __Pyx_INCREF(__pyx_int_0); __Pyx_CyFunction_Defaults(__pyx_defaults7, __pyx_t_4)->__pyx_arg_verbose = ((PyObject*)__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_6gofast_5tools_9coreutils_320__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_csv, __pyx_t_4) < 0) __PYX_ERR(0, 3070, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3078: **csvkws
3079: ) :
3080: """ Parse comma separated file or collect data from CSV.
3081:
3082: :param csv_fn: csv filename,or output CSV name if `data` is
3083: given and `todo` is set to ``write|dictwriter``.Otherwise the CSV
3084: output filename should be the `c.data` or the given variable name.
3085: :param data: Sequence Data in Python obj to write.
3086: :param todo: Action to perform with JSON:
3087: - reader|DictReader: Load data from the JSON file
3088: - writer|DictWriter: Write data from the Python object
3089: and create a CSV file
3090: :param savepath: If ``default`` should save the `csv_fn`
3091: If path does not exist, should save to the <'_savecsv_'>
3092: default path.
3093: :param fieldnames: is a sequence of keys that identify the order
3094: in which values in the dictionary passed to the `writerow()`
3095: method are written `csv_fn` file.
3096: :param savepath: If ``default`` should save the `csv_fn`
3097: If path does not exist, should save to the <'_savecsv_'>
3098: default path .
3099: :param verbose: int, control the verbosity. Output messages
3100: :param csvkws: additional keywords csv class arguments
3101:
3102: .. see also:: Read more about CSV module in:
3103: https://docs.python.org/3/library/csv.html or find some examples
3104: here https://www.programcreek.com/python/example/3190/csv.DictWriter
3105: or find some FAQS here:
3106: https://stackoverflow.com/questions/10373247/how-do-i-write-a-python-dictionary-to-a-csv-file
3107: ...
3108: :Example:
3109: >>> import gofast.tools.coreutils as FU
3110: >>> PATH = 'data/model'
3111: >>> k_ =['model', 'iter', 'mesh', 'data']
3112: >>> try :
3113: INVERS_KWS = {
3114: s +'_fn':os.path.join(PATH, file)
3115: for file in os.listdir(PATH)
3116: for s in k_ if file.lower().find(s)>=0
3117: }
3118: except :
3119: INVERS=dict()
3120: >>> TRES=[10, 66, 70, 100, 1000, 3000]# 7000]
3121: >>> LNS =['river water','fracture zone', 'MWG', 'LWG',
3122: 'granite', 'igneous rocks', 'basement rocks']
3123: >>> geo_kws ={'oc2d': INVERS_KWS,
3124: 'TRES':TRES, 'LN':LNS}
3125: >>> # write data and save to 'csvtest.csv' file
3126: >>> # here the `data` is a sequence of dictionary geo_kws
3127: >>> FU.parse_csv(csv_fn = 'csvtest.csv',data = [geo_kws],
3128: fieldnames = geo_kws.keys(),todo= 'dictwriter',
3129: savepath = 'data/saveCSV')
3130: # collect csv data from the 'csvtest.csv' file
3131: >>> FU.parse_csv(csv_fn ='data/saveCSV/csvtest.csv',
3132: todo='dictreader',fieldnames = geo_kws.keys()
3133: )
3134:
3135: """
+3136: todo, domsg =return_ctask(todo)
__Pyx_TraceLine(3136,0,__PYX_ERR(0, 3136, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_return_ctask); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_todo}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3136, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3136, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 3136, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3136, __pyx_L1_error) __pyx_L4_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_2); __pyx_t_2 = 0; __pyx_v_domsg = __pyx_t_3; __pyx_t_3 = 0;
3137:
+3138: if todo.find('write')>=0:
__Pyx_TraceLine(3138,0,__PYX_ERR(0, 3138, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_write}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_7) { /* … */ }
+3139: csv_fn = get_config_fname_from_varname(
__Pyx_TraceLine(3139,0,__PYX_ERR(0, 3139, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_config_fname_from_varname); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __Pyx_TraceLine(3140,0,__PYX_ERR(0, 3140, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data)) __PYX_ERR(0, 3139, __pyx_L1_error); /* … */ __Pyx_TraceLine(3139,0,__PYX_ERR(0, 3139, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_5))) __PYX_ERR(0, 3139, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_csv_fn, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
+3140: data, config_fname= csv_fn, config='.csv')
__pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_config_fname, __pyx_v_csv_fn) < 0) __PYX_ERR(0, 3140, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_config, __pyx_kp_u_csv_2) < 0) __PYX_ERR(0, 3140, __pyx_L1_error)
+3141: try :
__Pyx_TraceLine(3141,0,__PYX_ERR(0, 3141, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L11_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L11_try_end:; }
+3142: if todo =='reader':
__Pyx_TraceLine(3142,0,__PYX_ERR(0, 3142, __pyx_L6_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_reader, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3142, __pyx_L6_error) if (__pyx_t_7) { /* … */ goto __pyx_L12; }
+3143: with open (csv_fn, 'r') as csv_f :
__Pyx_TraceLine(3143,0,__PYX_ERR(0, 3143, __pyx_L6_error)) /*with:*/ { __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3143, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_csv_fn); __Pyx_GIVEREF(__pyx_v_csv_fn); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_csv_fn)) __PYX_ERR(0, 3143, __pyx_L6_error); __Pyx_INCREF(__pyx_n_u_r); __Pyx_GIVEREF(__pyx_n_u_r); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_n_u_r)) __PYX_ERR(0, 3143, __pyx_L6_error); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3143, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3143, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_2, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3143, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3143, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /*try:*/ { { /*try:*/ { __pyx_v_csv_f = __pyx_t_1; __pyx_t_1 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L22_try_end; __pyx_L17_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 3143, __pyx_L19_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3143, __pyx_L19_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3143, __pyx_L19_except_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__pyx_t_7 < 0) __PYX_ERR(0, 3143, __pyx_L19_except_error) __pyx_t_18 = (!__pyx_t_7); if (unlikely(__pyx_t_18)) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 3143, __pyx_L19_except_error) } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L18_exception_handled; } __pyx_L19_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L6_error; __pyx_L18_exception_handled:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_L22_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_11) { __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3143, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } goto __pyx_L16; } __pyx_L16:; } goto __pyx_L33; __pyx_L13_error:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L6_error; __pyx_L33:; }
+3144: csv_reader = csv.reader(csv_f) # iterator
__Pyx_TraceLine(3144,0,__PYX_ERR(0, 3144, __pyx_L17_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_csv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3144, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_reader); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3144, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_csv_f}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3144, __pyx_L17_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_csv_reader = __pyx_t_1; __pyx_t_1 = 0;
+3145: data =[ row for row in csv_reader]
__Pyx_TraceLine(3145,0,__PYX_ERR(0, 3145, __pyx_L17_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3145, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_csv_reader)) || PyTuple_CheckExact(__pyx_v_csv_reader)) { __pyx_t_5 = __pyx_v_csv_reader; __Pyx_INCREF(__pyx_t_5); __pyx_t_15 = 0; __pyx_t_16 = NULL; } else { __pyx_t_15 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_csv_reader); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3145, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3145, __pyx_L25_error) } for (;;) { if (likely(!__pyx_t_16)) { if (likely(PyList_CheckExact(__pyx_t_5))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3145, __pyx_L25_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_2); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 3145, __pyx_L25_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3145, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3145, __pyx_L25_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_15); __Pyx_INCREF(__pyx_t_2); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 3145, __pyx_L25_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3145, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_16(__pyx_t_5); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 3145, __pyx_L25_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_9genexpr35__pyx_v_row, __pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_9genexpr35__pyx_v_row))) __PYX_ERR(0, 3145, __pyx_L25_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_9genexpr35__pyx_v_row); __pyx_9genexpr35__pyx_v_row = 0; goto __pyx_L29_exit_scope; __pyx_L25_error:; __Pyx_XDECREF(__pyx_9genexpr35__pyx_v_row); __pyx_9genexpr35__pyx_v_row = 0; goto __pyx_L17_error; __pyx_L29_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
3146:
+3147: elif todo=='writer':
__Pyx_TraceLine(3147,0,__PYX_ERR(0, 3147, __pyx_L6_error)) __pyx_t_18 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_writer, Py_EQ)); if (unlikely((__pyx_t_18 < 0))) __PYX_ERR(0, 3147, __pyx_L6_error) if (__pyx_t_18) { /* … */ goto __pyx_L12; }
3148: # write without a blank line, --> new_line =''
+3149: with open(f'{csv_fn}.csv', 'w', newline ='',
__Pyx_TraceLine(3149,0,__PYX_ERR(0, 3149, __pyx_L6_error)) /*with:*/ { __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_csv_fn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_csv_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5)) __PYX_ERR(0, 3149, __pyx_L6_error); __Pyx_INCREF(__pyx_n_u_w); __Pyx_GIVEREF(__pyx_n_u_w); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_w)) __PYX_ERR(0, 3149, __pyx_L6_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_newline, __pyx_kp_u__22) < 0) __PYX_ERR(0, 3149, __pyx_L6_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 3149, __pyx_L6_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3149, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3149, __pyx_L34_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_new_csvf = __pyx_t_2; __pyx_t_2 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L43_try_end; __pyx_L38_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 3149, __pyx_L40_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3149, __pyx_L40_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3149, __pyx_L40_except_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__pyx_t_18 < 0) __PYX_ERR(0, 3149, __pyx_L40_except_error) __pyx_t_7 = (!__pyx_t_18); if (unlikely(__pyx_t_7)) { __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_5, __pyx_t_2); __pyx_t_3 = 0; __pyx_t_5 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 3149, __pyx_L40_except_error) } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L39_exception_handled; } __pyx_L40_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); goto __pyx_L6_error; __pyx_L39_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); __pyx_L43_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_11) { __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3149, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } goto __pyx_L37; } __pyx_L37:; } goto __pyx_L47; __pyx_L34_error:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L6_error; __pyx_L47:; }
3150: encoding ='utf8') as new_csvf:
+3151: csv_writer = csv.writer(new_csvf, **csvkws)
__Pyx_TraceLine(3151,0,__PYX_ERR(0, 3151, __pyx_L38_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_csv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3151, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_writer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3151, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3151, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_new_csvf); __Pyx_GIVEREF(__pyx_v_new_csvf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_new_csvf)) __PYX_ERR(0, 3151, __pyx_L38_error); __pyx_t_5 = PyDict_Copy(__pyx_v_csvkws); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3151, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3151, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_csv_writer = __pyx_t_3; __pyx_t_3 = 0;
+3152: csv_writer.writerows(data) if len(
__Pyx_TraceLine(3152,0,__PYX_ERR(0, 3152, __pyx_L38_error)) __pyx_t_15 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3152, __pyx_L38_error) /* … */ __Pyx_TraceLine(3152,0,__PYX_ERR(0, 3152, __pyx_L38_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_csv_writer, __pyx_n_s_writerows); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3152, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_data}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3152, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_3 = __pyx_t_5; __pyx_t_5 = 0; } else {
+3153: data ) > 1 else csv_writer.writerow(data)
__Pyx_TraceLine(3153,0,__PYX_ERR(0, 3153, __pyx_L38_error)) __pyx_t_18 = (__pyx_t_15 > 1); if (__pyx_t_18) { /* … */ __Pyx_TraceLine(3153,0,__PYX_ERR(0, 3153, __pyx_L38_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_csv_writer, __pyx_n_s_writerow); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3153, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_data}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3153, __pyx_L38_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_3 = __pyx_t_5; __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3154: # for row in data:
3155: # csv_writer.writerow(row)
+3156: elif todo=='dictreader':
__Pyx_TraceLine(3156,0,__PYX_ERR(0, 3156, __pyx_L6_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dictreader, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3156, __pyx_L6_error) if (__pyx_t_7) { /* … */ goto __pyx_L12; }
+3157: with open (csv_fn, 'r', encoding ='utf8') as csv_f :
__Pyx_TraceLine(3157,0,__PYX_ERR(0, 3157, __pyx_L6_error)) /*with:*/ { __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3157, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_csv_fn); __Pyx_GIVEREF(__pyx_v_csv_fn); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csv_fn)) __PYX_ERR(0, 3157, __pyx_L6_error); __Pyx_INCREF(__pyx_n_u_r); __Pyx_GIVEREF(__pyx_n_u_r); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_r)) __PYX_ERR(0, 3157, __pyx_L6_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3157, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_encoding, __pyx_n_u_utf8) < 0) __PYX_ERR(0, 3157, __pyx_L6_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3157, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3157, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3157, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3157, __pyx_L48_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __pyx_v_csv_f = __pyx_t_2; __pyx_t_2 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L57_try_end; __pyx_L52_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_2) < 0) __PYX_ERR(0, 3157, __pyx_L54_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3157, __pyx_L54_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3157, __pyx_L54_except_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__pyx_t_7 < 0) __PYX_ERR(0, 3157, __pyx_L54_except_error) __pyx_t_18 = (!__pyx_t_7); if (unlikely(__pyx_t_18)) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_5, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_5 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 3157, __pyx_L54_except_error) } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L53_exception_handled; } __pyx_L54_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L6_error; __pyx_L53_exception_handled:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_L57_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_11) { __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3157, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } goto __pyx_L51; } __pyx_L51:; } goto __pyx_L61; __pyx_L48_error:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L6_error; __pyx_L61:; }
3158: # generate an iterator obj
+3159: csv_reader= csv.DictReader (csv_f, fieldnames= fieldnames)
__Pyx_TraceLine(3159,0,__PYX_ERR(0, 3159, __pyx_L52_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_csv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3159, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DictReader); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3159, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3159, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_csv_f); __Pyx_GIVEREF(__pyx_v_csv_f); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csv_f)) __PYX_ERR(0, 3159, __pyx_L52_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3159, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_fieldnames, __pyx_v_fieldnames) < 0) __PYX_ERR(0, 3159, __pyx_L52_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3159, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_csv_reader = __pyx_t_1; __pyx_t_1 = 0;
3160: # return csvobj as a list of dicts
+3161: data = list(csv_reader)
__Pyx_TraceLine(3161,0,__PYX_ERR(0, 3161, __pyx_L52_error)) __pyx_t_1 = PySequence_List(__pyx_v_csv_reader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3161, __pyx_L52_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
3162:
+3163: elif todo=='dictwriter':
__Pyx_TraceLine(3163,0,__PYX_ERR(0, 3163, __pyx_L6_error)) __pyx_t_18 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dictwriter, Py_EQ)); if (unlikely((__pyx_t_18 < 0))) __PYX_ERR(0, 3163, __pyx_L6_error) if (__pyx_t_18) { /* … */ } __pyx_L12:;
+3164: with open(f'{csv_fn}.csv', 'w') as new_csvf:
__Pyx_TraceLine(3164,0,__PYX_ERR(0, 3164, __pyx_L6_error)) /*with:*/ { __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_csv_fn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3164, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_csv_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3164, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3164, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5)) __PYX_ERR(0, 3164, __pyx_L6_error); __Pyx_INCREF(__pyx_n_u_w); __Pyx_GIVEREF(__pyx_n_u_w); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_w)) __PYX_ERR(0, 3164, __pyx_L6_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3164, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3164, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_5, __pyx_n_s_enter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3164, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3164, __pyx_L62_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /*try:*/ { { /*try:*/ { __pyx_v_new_csvf = __pyx_t_1; __pyx_t_1 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L71_try_end; __pyx_L66_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 3164, __pyx_L68_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1); __pyx_t_5 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3164, __pyx_L68_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3164, __pyx_L68_except_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__pyx_t_18 < 0) __PYX_ERR(0, 3164, __pyx_L68_except_error) __pyx_t_7 = (!__pyx_t_18); if (unlikely(__pyx_t_7)) { __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_2, __pyx_t_1); __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __PYX_ERR(0, 3164, __pyx_L68_except_error) } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L67_exception_handled; } __pyx_L68_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); goto __pyx_L6_error; __pyx_L67_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); __pyx_L71_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_11) { __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3164, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } goto __pyx_L65; } __pyx_L65:; } goto __pyx_L76; __pyx_L62_error:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L6_error; __pyx_L76:; }
+3165: csv_writer = csv.DictWriter(new_csvf, **csvkws)
__Pyx_TraceLine(3165,0,__PYX_ERR(0, 3165, __pyx_L66_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_csv); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3165, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DictWriter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3165, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3165, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_new_csvf); __Pyx_GIVEREF(__pyx_v_new_csvf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_new_csvf)) __PYX_ERR(0, 3165, __pyx_L66_error); __pyx_t_2 = PyDict_Copy(__pyx_v_csvkws); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3165, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3165, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_csv_writer = __pyx_t_3; __pyx_t_3 = 0;
+3166: if header:
__Pyx_TraceLine(3166,0,__PYX_ERR(0, 3166, __pyx_L66_error)) __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely((__pyx_t_18 < 0))) __PYX_ERR(0, 3166, __pyx_L66_error) if (__pyx_t_18) { /* … */ }
+3167: csv_writer.writeheader()
__Pyx_TraceLine(3167,0,__PYX_ERR(0, 3167, __pyx_L66_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_csv_writer, __pyx_n_s_writeheader); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3167, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3167, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3168: # DictWriter.writerows()expect a list of dicts,
3169: # while DictWriter.writerow() expect a single row of dict.
+3170: csv_writer.writerow(data) if isinstance(
__Pyx_TraceLine(3170,0,__PYX_ERR(0, 3170, __pyx_L66_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_csv_writer, __pyx_n_s_writerow); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3170, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3170, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else {
+3171: data , dict) else csv_writer.writerows(data)
__Pyx_TraceLine(3171,0,__PYX_ERR(0, 3171, __pyx_L66_error)) __pyx_t_18 = PyDict_Check(__pyx_v_data); if (__pyx_t_18) { /* … */ __Pyx_TraceLine(3171,0,__PYX_ERR(0, 3171, __pyx_L66_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_csv_writer, __pyx_n_s_writerows); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3171, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3171, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3172:
+3173: except csv.Error:
__Pyx_TraceLine(3173,0,__PYX_ERR(0, 3173, __pyx_L8_except_error)) __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_csv); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3173, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Error); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3173, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_4 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_19); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_3 = 0; if (__pyx_t_4) { __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 3173, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1);
+3174: raise csv.Error(f"Unable {domsg} CSV {csv_fn!r} file. "
__Pyx_TraceLine(3174,0,__PYX_ERR(0, 3174, __pyx_L8_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_csv); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Error); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_15 = 0; __pyx_t_21 = 127; __Pyx_INCREF(__pyx_kp_u_Unable); __pyx_t_15 += 7; __Pyx_GIVEREF(__pyx_kp_u_Unable); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Unable); __pyx_t_22 = __Pyx_PyObject_FormatSimple(__pyx_v_domsg, __pyx_empty_unicode); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_21 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) > __pyx_t_21) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) : __pyx_t_21; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_22); __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_22); __pyx_t_22 = 0; __Pyx_INCREF(__pyx_kp_u_CSV); __pyx_t_15 += 5; __Pyx_GIVEREF(__pyx_kp_u_CSV); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_CSV); __pyx_t_22 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_csv_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_21 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) > __pyx_t_21) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) : __pyx_t_21; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_22); __Pyx_GIVEREF(__pyx_t_22); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_22); __pyx_t_22 = 0; __Pyx_INCREF(__pyx_kp_u_file_Please_check_your_file); __pyx_t_15 += 30; __Pyx_GIVEREF(__pyx_kp_u_file_Please_check_your_file); PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_kp_u_file_Please_check_your_file); __pyx_t_22 = __Pyx_PyUnicode_Join(__pyx_t_5, 5, __pyx_t_15, __pyx_t_21); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_20))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_20); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_20, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_22}; __pyx_t_19 = __Pyx_PyObject_FastCall(__pyx_t_20, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3174, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; } __Pyx_Raise(__pyx_t_19, 0, 0, 0); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __PYX_ERR(0, 3174, __pyx_L8_except_error) }
3175: "Please check your file.")
+3176: except:
__Pyx_TraceLine(3176,0,__PYX_ERR(0, 3176, __pyx_L8_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 3176, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3);
3177:
+3178: msg =''.join([
__Pyx_TraceLine(3178,0,__PYX_ERR(0, 3178, __pyx_L8_except_error)) __pyx_t_19 = PyList_New(1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3178, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_22); if (__Pyx_PyList_SET_ITEM(__pyx_t_19, 0, __pyx_t_22)) __PYX_ERR(0, 3178, __pyx_L8_except_error); __pyx_t_22 = 0; __pyx_t_22 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_19); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3178, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_22); __pyx_t_22 = 0;
+3179: f"{'Unrecognizable file' if todo.find('read')>=0 else'Unable to write'}"
__Pyx_TraceLine(3179,0,__PYX_ERR(0, 3179, __pyx_L8_except_error)) __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3179, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_22))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_22); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_22, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_n_u_read}; __pyx_t_20 = __Pyx_PyObject_FastCall(__pyx_t_22, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3179, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; } __pyx_t_22 = PyObject_RichCompare(__pyx_t_20, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3179, __pyx_L8_except_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_22); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3179, __pyx_L8_except_error) __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; if (__pyx_t_7) { __Pyx_INCREF(__pyx_kp_u_Unrecognizable_file); __pyx_t_19 = __pyx_kp_u_Unrecognizable_file; } else { __Pyx_INCREF(__pyx_kp_u_Unable_to_write); __pyx_t_19 = __pyx_kp_u_Unable_to_write; } __pyx_t_22 = __Pyx_PyUnicode_Unicode(__pyx_t_19); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3179, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
3180: ])
3181:
+3182: raise TypeError(f'{msg} {csv_fn!r}. Please check your'
__Pyx_TraceLine(3182,0,__PYX_ERR(0, 3182, __pyx_L8_except_error)) __pyx_t_22 = PyTuple_New(6); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3182, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __pyx_t_15 = 0; __pyx_t_21 = 127; __pyx_t_19 = __Pyx_PyUnicode_Unicode(__pyx_v_msg); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3182, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_21 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_21) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_21; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_15 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_22, 1, __pyx_kp_u__14); __pyx_t_19 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_csv_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3182, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_21 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_21) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_21; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_22, 2, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u_Please_check_your); __pyx_t_15 += 20; __Pyx_GIVEREF(__pyx_kp_u_Please_check_your); PyTuple_SET_ITEM(__pyx_t_22, 3, __pyx_kp_u_Please_check_your); /* … */ __Pyx_TraceLine(3182,0,__PYX_ERR(0, 3182, __pyx_L8_except_error)) __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_22, 6, __pyx_t_15, __pyx_t_21); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3182, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; __pyx_t_22 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3182, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_22, 0, 0, 0); __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0; __PYX_ERR(0, 3182, __pyx_L8_except_error) }
+3183: f" {'file' if todo.find('read')>=0 else 'data'}.")
__Pyx_TraceLine(3183,0,__PYX_ERR(0, 3183, __pyx_L8_except_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3183, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_23 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_23)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_23); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_n_u_read}; __pyx_t_20 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0; if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3183, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = PyObject_RichCompare(__pyx_t_20, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3183, __pyx_L8_except_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3183, __pyx_L8_except_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_7) { __Pyx_INCREF(__pyx_n_u_file); __pyx_t_19 = __pyx_n_u_file; } else { __Pyx_INCREF(__pyx_n_u_data); __pyx_t_19 = __pyx_n_u_data; } __pyx_t_5 = __Pyx_PyUnicode_Unicode(__pyx_t_19); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3183, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_t_21 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_21) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_21; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_22, 4, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_15 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_22, 5, __pyx_kp_u__26);
+3184: cparser_manager(f'{csv_fn}.csv',savepath, todo=todo, dpath='_savecsv_',
__Pyx_TraceLine(3184,0,__PYX_ERR(0, 3184, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_cparser_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_csv_fn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_csv_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 3184, __pyx_L1_error); __Pyx_INCREF(__pyx_v_savepath); __Pyx_GIVEREF(__pyx_v_savepath); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_savepath)) __PYX_ERR(0, 3184, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_todo, __pyx_v_todo) < 0) __PYX_ERR(0, 3184, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dpath, __pyx_n_u_savecsv) < 0) __PYX_ERR(0, 3184, __pyx_L1_error) /* … */ __Pyx_TraceLine(3184,0,__PYX_ERR(0, 3184, __pyx_L1_error)) __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_22); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
+3185: verbose=verbose , config='CSV' )
__Pyx_TraceLine(3185,0,__PYX_ERR(0, 3185, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_verbose, __pyx_v_verbose) < 0) __PYX_ERR(0, 3184, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_config, __pyx_n_u_CSV_2) < 0) __PYX_ERR(0, 3184, __pyx_L1_error)
3186:
+3187: return data
__Pyx_TraceLine(3187,0,__PYX_ERR(0, 3187, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
3188:
+3189: def return_ctask (todo:Optional[str]=None) -> Tuple [str, str]:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_118return_ctask(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_117return_ctask, " Get the convenient task to do if users misinput the `todo` action.\n \n :param todo: Action to perform: \n - load: Load data from the config [YAML|CSV|JSON] file\n - dump: serialize data from the Python object and \n create a config [YAML|CSV|JSON] file."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_118return_ctask = {"return_ctask", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_118return_ctask, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_117return_ctask}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_118return_ctask(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_todo = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("return_ctask (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_todo,0}; PyObject* values[1] = {0}; values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3189, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "return_ctask") < 0)) __PYX_ERR(0, 3189, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_todo = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("return_ctask", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 3189, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.return_ctask", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_117return_ctask(__pyx_self, __pyx_v_todo); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_117return_ctask(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_todo) { PyObject *__pyx_v_p_csv = 0; PyObject *__pyx_v_ltags = NULL; PyObject *__pyx_v_dtags = NULL; PyObject *__pyx_v_domsg = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__155) __Pyx_TraceCall("return_ctask", __pyx_f[0], 3189, 0, __PYX_ERR(0, 3189, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_todo); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.return_ctask", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_p_csv); __Pyx_XDECREF(__pyx_v_ltags); __Pyx_XDECREF(__pyx_v_dtags); __Pyx_XDECREF(__pyx_v_domsg); __Pyx_XDECREF(__pyx_v_todo); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__430 = PyTuple_Pack(6, __pyx_n_s_todo, __pyx_n_s_p_csv, __pyx_n_s_p_csv, __pyx_n_s_ltags, __pyx_n_s_dtags, __pyx_n_s_domsg); if (unlikely(!__pyx_tuple__430)) __PYX_ERR(0, 3189, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__430); __Pyx_GIVEREF(__pyx_tuple__430); /* … */ __Pyx_TraceLine(3189,0,__PYX_ERR(0, 3189, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_todo, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 3189, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_kp_s_Tuple_str_str) < 0) __PYX_ERR(0, 3189, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_118return_ctask, 0, __pyx_n_s_return_ctask, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__155)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3189, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__62); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_return_ctask, __pyx_t_2) < 0) __PYX_ERR(0, 3189, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__155 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__430, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_return_ctask, 3189, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__155)) __PYX_ERR(0, 3189, __pyx_L1_error)
3190: """ Get the convenient task to do if users misinput the `todo` action.
3191:
3192: :param todo: Action to perform:
3193: - load: Load data from the config [YAML|CSV|JSON] file
3194: - dump: serialize data from the Python object and
3195: create a config [YAML|CSV|JSON] file."""
3196:
+3197: def p_csv(v, cond='dict', base='reader'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_12return_ctask_1p_csv(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_12return_ctask_p_csv, " Read csv instead. \n :param v: str, value to do \n :param cond: str, condition if found in the value `v`. \n :param base: str, base task to do if condition `cond` is not met. \n \n :Example: \n \n >>> todo = 'readingbook' \n >>> p_csv(todo) <=> 'dictreader' if todo.find('dict')>=0 else 'reader' \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_12return_ctask_1p_csv = {"p_csv", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_12return_ctask_1p_csv, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_12return_ctask_p_csv}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_12return_ctask_1p_csv(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_v = 0; PyObject *__pyx_v_cond = 0; PyObject *__pyx_v_base = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("p_csv (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_v,&__pyx_n_s_cond,&__pyx_n_s_base,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_dict_2))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_reader))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_v)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3197, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cond); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3197, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_base); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3197, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "p_csv") < 0)) __PYX_ERR(0, 3197, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_v = values[0]; __pyx_v_cond = values[1]; __pyx_v_base = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("p_csv", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 3197, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.return_ctask.p_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_12return_ctask_p_csv(__pyx_self, __pyx_v_v, __pyx_v_cond, __pyx_v_base); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_12return_ctask_p_csv(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_v, PyObject *__pyx_v_cond, PyObject *__pyx_v_base) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("p_csv", __pyx_f[0], 3197, 0, __PYX_ERR(0, 3197, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.return_ctask.p_csv", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__156 = PyTuple_Pack(3, __pyx_n_s_v, __pyx_n_s_cond, __pyx_n_s_base); if (unlikely(!__pyx_tuple__156)) __PYX_ERR(0, 3197, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__156); __Pyx_GIVEREF(__pyx_tuple__156); __pyx_codeobj__157 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__156, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_p_csv, 3197, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__157)) __PYX_ERR(0, 3197, __pyx_L1_error) /* … */ __Pyx_TraceLine(3197,0,__PYX_ERR(0, 3197, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_12return_ctask_1p_csv, 0, __pyx_n_s_return_ctask_locals_p_csv, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__157)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3197, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__158); __pyx_v_p_csv = __pyx_t_1; __pyx_t_1 = 0; __pyx_tuple__158 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u_dict_2), ((PyObject*)__pyx_n_u_reader)); if (unlikely(!__pyx_tuple__158)) __PYX_ERR(0, 3197, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__158); __Pyx_GIVEREF(__pyx_tuple__158);
3198: """ Read csv instead.
3199: :param v: str, value to do
3200: :param cond: str, condition if found in the value `v`.
3201: :param base: str, base task to do if condition `cond` is not met.
3202:
3203: :Example:
3204:
3205: >>> todo = 'readingbook'
3206: >>> p_csv(todo) <=> 'dictreader' if todo.find('dict')>=0 else 'reader'
3207: """
+3208: return f'{cond}{base}' if v.find(cond) >=0 else base
__Pyx_TraceLine(3208,0,__PYX_ERR(0, 3208, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_cond}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_cond, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_base, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else { __Pyx_INCREF(__pyx_v_base); __pyx_t_1 = __pyx_v_base; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
3209:
+3210: ltags = ('load', 'recover', True, 'fetch')
__Pyx_TraceLine(3210,0,__PYX_ERR(0, 3210, __pyx_L1_error)) __Pyx_INCREF(__pyx_tuple__159); __pyx_v_ltags = __pyx_tuple__159; /* … */ __pyx_tuple__159 = PyTuple_Pack(4, __pyx_n_u_load, __pyx_n_u_recover, Py_True, __pyx_n_u_fetch); if (unlikely(!__pyx_tuple__159)) __PYX_ERR(0, 3210, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__159); __Pyx_GIVEREF(__pyx_tuple__159);
+3211: dtags = ('serialized', 'dump', 'save', 'write','serialize')
__Pyx_TraceLine(3211,0,__PYX_ERR(0, 3211, __pyx_L1_error)) __Pyx_INCREF(__pyx_tuple__160); __pyx_v_dtags = __pyx_tuple__160; /* … */ __pyx_tuple__160 = PyTuple_Pack(5, __pyx_n_u_serialized, __pyx_n_u_dump, __pyx_n_u_save, __pyx_n_u_write, __pyx_n_u_serialize); if (unlikely(!__pyx_tuple__160)) __PYX_ERR(0, 3211, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__160); __Pyx_GIVEREF(__pyx_tuple__160);
+3212: if todo is None:
__Pyx_TraceLine(3212,0,__PYX_ERR(0, 3212, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_todo == Py_None); if (unlikely(__pyx_t_2)) { /* … */ }
+3213: raise ValueError('NoneType action can not be perform. Please '
__Pyx_TraceLine(3213,0,__PYX_ERR(0, 3213, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__161, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 3213, __pyx_L1_error) /* … */ __pyx_tuple__161 = PyTuple_Pack(1, __pyx_kp_u_NoneType_action_can_not_be_perfo); if (unlikely(!__pyx_tuple__161)) __PYX_ERR(0, 3213, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__161); __Pyx_GIVEREF(__pyx_tuple__161);
3214: 'specify your action: `load` or `dump`?' )
3215:
+3216: todo =str(todo).lower()
__Pyx_TraceLine(3216,0,__PYX_ERR(0, 3216, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_todo); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3216, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_1); __pyx_t_1 = 0;
+3217: ltags = list(ltags) + [todo] if todo=='loads' else ltags
__Pyx_TraceLine(3217,0,__PYX_ERR(0, 3217, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_loads, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3217, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_4 = PySequence_List(__pyx_v_ltags); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_todo); __Pyx_GIVEREF(__pyx_v_todo); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_todo)) __PYX_ERR(0, 3217, __pyx_L1_error); __pyx_t_6 = PyNumber_Add(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3217, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; } else { __Pyx_INCREF(__pyx_v_ltags); __pyx_t_1 = __pyx_v_ltags; } __Pyx_DECREF_SET(__pyx_v_ltags, __pyx_t_1); __pyx_t_1 = 0;
+3218: dtags= list(dtags) +[todo] if todo=='dumps' else dtags
__Pyx_TraceLine(3218,0,__PYX_ERR(0, 3218, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dumps, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3218, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_6 = PySequence_List(__pyx_v_dtags); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_todo); __Pyx_GIVEREF(__pyx_v_todo); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_todo)) __PYX_ERR(0, 3218, __pyx_L1_error); __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else { __Pyx_INCREF(__pyx_v_dtags); __pyx_t_1 = __pyx_v_dtags; } __Pyx_DECREF_SET(__pyx_v_dtags, __pyx_t_1); __pyx_t_1 = 0;
3219:
+3220: if todo in ltags:
__Pyx_TraceLine(3220,0,__PYX_ERR(0, 3220, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_todo, __pyx_v_ltags, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3220, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L4; }
+3221: todo = 'loads' if todo=='loads' else 'load'
__Pyx_TraceLine(3221,0,__PYX_ERR(0, 3221, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_loads, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3221, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_n_u_loads); __pyx_t_1 = __pyx_n_u_loads; } else { __Pyx_INCREF(__pyx_n_u_load); __pyx_t_1 = __pyx_n_u_load; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_1); __pyx_t_1 = 0;
+3222: domsg= 'to parse'
__Pyx_TraceLine(3222,0,__PYX_ERR(0, 3222, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_to_parse); __pyx_v_domsg = __pyx_kp_u_to_parse;
+3223: elif todo in dtags:
__Pyx_TraceLine(3223,0,__PYX_ERR(0, 3223, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_todo, __pyx_v_dtags, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3223, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L4; }
+3224: todo = 'dumps' if todo=='dumps' else 'dump'
__Pyx_TraceLine(3224,0,__PYX_ERR(0, 3224, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dumps, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3224, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_n_u_dumps); __pyx_t_1 = __pyx_n_u_dumps; } else { __Pyx_INCREF(__pyx_n_u_dump); __pyx_t_1 = __pyx_n_u_dump; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_1); __pyx_t_1 = 0;
+3225: domsg ='to serialize'
__Pyx_TraceLine(3225,0,__PYX_ERR(0, 3225, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_to_serialize); __pyx_v_domsg = __pyx_kp_u_to_serialize;
+3226: elif todo.find('read')>=0:
__Pyx_TraceLine(3226,0,__PYX_ERR(0, 3226, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_read}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3226, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L4; }
+3227: todo = p_csv(todo)
__Pyx_TraceLine(3227,0,__PYX_ERR(0, 3227, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_v_p_csv, __pyx_v_todo); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_4); __pyx_t_4 = 0;
+3228: domsg= 'to read'
__Pyx_TraceLine(3228,0,__PYX_ERR(0, 3228, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_to_read); __pyx_v_domsg = __pyx_kp_u_to_read;
+3229: elif todo.find('write')>=0:
__Pyx_TraceLine(3229,0,__PYX_ERR(0, 3229, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_write}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyObject_RichCompare(__pyx_t_4, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(__pyx_t_2)) { /* … */ goto __pyx_L4; }
+3230: todo = p_csv(todo, base ='writer')
__Pyx_TraceLine(3230,0,__PYX_ERR(0, 3230, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_todo); __Pyx_GIVEREF(__pyx_v_todo); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_todo)) __PYX_ERR(0, 3230, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_base, __pyx_n_u_writer) < 0) __PYX_ERR(0, 3230, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_p_csv, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_3); __pyx_t_3 = 0;
+3231: domsg =' to write'
__Pyx_TraceLine(3231,0,__PYX_ERR(0, 3231, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_to_write); __pyx_v_domsg = __pyx_kp_u_to_write;
3232:
3233: else :
+3234: raise ValueError(f'Wrong action {todo!r}. Please select'
__Pyx_TraceLine(3234,0,__PYX_ERR(0, 3234, __pyx_L1_error)) /*else*/ { __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Wrong_action); __pyx_t_7 += 13; __Pyx_GIVEREF(__pyx_kp_u_Wrong_action); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Wrong_action); __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_todo), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_Please_select_the_right_action); __pyx_t_7 += 112; __Pyx_GIVEREF(__pyx_kp_u_Please_select_the_right_action); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_Please_select_the_right_action); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3234, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 3234, __pyx_L1_error) } __pyx_L4:;
3235: f' the right action to perform: `load` or `dump`?'
3236: ' for [JSON|YAML] and `read` or `write`? '
3237: 'for [CSV].')
+3238: return todo, domsg
__Pyx_TraceLine(3238,0,__PYX_ERR(0, 3238, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_todo); __Pyx_GIVEREF(__pyx_v_todo); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_todo)) __PYX_ERR(0, 3238, __pyx_L1_error); __Pyx_INCREF(__pyx_v_domsg); __Pyx_GIVEREF(__pyx_v_domsg); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_domsg)) __PYX_ERR(0, 3238, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
3239:
+3240: def parse_yaml (yml_fn:str =None, data=None,
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_322__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 3240, 0, __PYX_ERR(0, 3240, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(3241,0,__PYX_ERR(0, 3241, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None)) __PYX_ERR(0, 3240, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None)) __PYX_ERR(0, 3240, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_n_u_load));
__Pyx_GIVEREF(((PyObject*)__pyx_n_u_load));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject*)__pyx_n_u_load))) __PYX_ERR(0, 3240, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, Py_None)) __PYX_ERR(0, 3240, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_verbose);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_verbose);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 4, __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self)->__pyx_arg_verbose)) __PYX_ERR(0, 3240, __pyx_L1_error);
/* … */
__Pyx_TraceLine(3240,0,__PYX_ERR(0, 3240, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 3240, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 3240, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_120parse_yaml(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_119parse_yaml, " Parse yml file and collect data from YAML config file. \n \n :param yml_fn: yaml filename and can be the output YAML name if `data` is \n given and `todo` is set to ``dump``.Otherwise the YAML output filename \n should be the `data` or the given variable name.\n :param data: Data in Python obj to serialize. \n :param todo: Action to perform with YAML: \n - load: Load data from the YAML file \n - dump: serialize data from the Python object and create a YAML file\n :param savepath: If ``default`` should save the `yml_fn` \n to the default path otherwise should store to the convenient path.\n If path does not exist, should set to the default path.\n :param verbose: int, control the verbosity. Output messages\n \n .. see also:: Read more about YAML file https://pynative.com/python-yaml/\n or https://python.land/data-processing/python-yaml and download YAML \n at https://pypi.org/project/PyYAML/\n ...\n\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_120parse_yaml = {"parse_yaml", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_120parse_yaml, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_119parse_yaml};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_120parse_yaml(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_yml_fn = 0;
PyObject *__pyx_v_data = 0;
PyObject *__pyx_v_todo = 0;
PyObject *__pyx_v_savepath = 0;
PyObject *__pyx_v_verbose = 0;
PyObject *__pyx_v_ymlkws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("parse_yaml (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_ymlkws = PyDict_New(); if (unlikely(!__pyx_v_ymlkws)) return NULL;
__Pyx_GOTREF(__pyx_v_ymlkws);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_yml_fn,&__pyx_n_s_data,&__pyx_n_s_todo,&__pyx_n_s_savepath,&__pyx_n_s_verbose,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults8 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_self);
values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_load)));
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_ymlkws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_119parse_yaml(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_yml_fn, PyObject *__pyx_v_data, PyObject *__pyx_v_todo, PyObject *__pyx_v_savepath, PyObject *__pyx_v_verbose, PyObject *__pyx_v_ymlkws) {
PyObject *__pyx_v_domsg = NULL;
PyObject *__pyx_v_fy = NULL;
PyObject *__pyx_v_fw = NULL;
PyObject *__pyx_v_msg = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__162)
__Pyx_TraceCall("parse_yaml", __pyx_f[0], 3240, 0, __PYX_ERR(0, 3240, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_yml_fn);
__Pyx_INCREF(__pyx_v_data);
__Pyx_INCREF(__pyx_v_todo);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_15);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_XDECREF(__pyx_t_21);
__Pyx_AddTraceback("gofast.tools.coreutils.parse_yaml", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_domsg);
__Pyx_XDECREF(__pyx_v_fy);
__Pyx_XDECREF(__pyx_v_fw);
__Pyx_XDECREF(__pyx_v_msg);
__Pyx_XDECREF(__pyx_v_yml_fn);
__Pyx_XDECREF(__pyx_v_data);
__Pyx_XDECREF(__pyx_v_todo);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__431 = PyTuple_Pack(10, __pyx_n_s_yml_fn, __pyx_n_s_data, __pyx_n_s_todo, __pyx_n_s_savepath, __pyx_n_s_verbose, __pyx_n_s_ymlkws, __pyx_n_s_domsg, __pyx_n_s_fy, __pyx_n_s_fw, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__431)) __PYX_ERR(0, 3240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__431);
__Pyx_GIVEREF(__pyx_tuple__431);
/* … */
__Pyx_TraceLine(3240,0,__PYX_ERR(0, 3240, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_yml_fn, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3240, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_verbose, __pyx_n_s_int) < 0) __PYX_ERR(0, 3240, __pyx_L1_error)
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_120parse_yaml, 0, __pyx_n_s_parse_yaml, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__162)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3240, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults8), 1)) __PYX_ERR(0, 3240, __pyx_L1_error)
__pyx_codeobj__162 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__431, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parse_yaml, 3240, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__162)) __PYX_ERR(0, 3240, __pyx_L1_error)
+3241: todo='load', savepath=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_verbose); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_yml_fn); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3240, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3240, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3240, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3240, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3240, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_ymlkws, values + 0, kwd_pos_args, "parse_yaml") < 0)) __PYX_ERR(0, 3240, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_yml_fn = ((PyObject*)values[0]); __pyx_v_data = values[1]; __pyx_v_todo = values[2]; __pyx_v_savepath = values[3]; __pyx_v_verbose = ((PyObject*)values[4]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parse_yaml", 0, 0, 5, __pyx_nargs); __PYX_ERR(0, 3240, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_ymlkws); __pyx_v_ymlkws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.parse_yaml", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_yml_fn), (&PyUnicode_Type), 1, "yml_fn", 1))) __PYX_ERR(0, 3240, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_verbose), (&PyInt_Type), 0, "verbose", 1))) __PYX_ERR(0, 3242, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_119parse_yaml(__pyx_self, __pyx_v_yml_fn, __pyx_v_data, __pyx_v_todo, __pyx_v_savepath, __pyx_v_verbose, __pyx_v_ymlkws);
+3242: verbose:int =0, **ymlkws) :
__Pyx_TraceLine(3242,0,__PYX_ERR(0, 3242, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_0)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_0))) __PYX_ERR(0, 3242, __pyx_L1_error) __Pyx_INCREF(__pyx_int_0); __Pyx_CyFunction_Defaults(__pyx_defaults8, __pyx_t_4)->__pyx_arg_verbose = ((PyObject*)__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_6gofast_5tools_9coreutils_322__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_yaml, __pyx_t_4) < 0) __PYX_ERR(0, 3240, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3243: """ Parse yml file and collect data from YAML config file.
3244:
3245: :param yml_fn: yaml filename and can be the output YAML name if `data` is
3246: given and `todo` is set to ``dump``.Otherwise the YAML output filename
3247: should be the `data` or the given variable name.
3248: :param data: Data in Python obj to serialize.
3249: :param todo: Action to perform with YAML:
3250: - load: Load data from the YAML file
3251: - dump: serialize data from the Python object and create a YAML file
3252: :param savepath: If ``default`` should save the `yml_fn`
3253: to the default path otherwise should store to the convenient path.
3254: If path does not exist, should set to the default path.
3255: :param verbose: int, control the verbosity. Output messages
3256:
3257: .. see also:: Read more about YAML file https://pynative.com/python-yaml/
3258: or https://python.land/data-processing/python-yaml and download YAML
3259: at https://pypi.org/project/PyYAML/
3260: ...
3261:
3262: """
3263:
+3264: todo, domsg =return_ctask(todo)
__Pyx_TraceLine(3264,0,__PYX_ERR(0, 3264, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_return_ctask); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_todo}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3264, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) __PYX_ERR(0, 3264, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3264, __pyx_L1_error) __pyx_L4_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_todo, __pyx_t_2); __pyx_t_2 = 0; __pyx_v_domsg = __pyx_t_3; __pyx_t_3 = 0;
3265: #in the case user use dumps or loads with 's'at the end
+3266: if todo.find('dump')>= 0:
__Pyx_TraceLine(3266,0,__PYX_ERR(0, 3266, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_dump}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3266, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_7) { /* … */ }
+3267: todo='dump'
__Pyx_TraceLine(3267,0,__PYX_ERR(0, 3267, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_dump); __Pyx_DECREF_SET(__pyx_v_todo, __pyx_n_u_dump);
+3268: if todo.find('load')>=0:
__Pyx_TraceLine(3268,0,__PYX_ERR(0, 3268, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_todo, __pyx_n_s_find); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_n_u_load}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3268, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3268, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_7) { /* … */ }
+3269: todo='load'
__Pyx_TraceLine(3269,0,__PYX_ERR(0, 3269, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_load); __Pyx_DECREF_SET(__pyx_v_todo, __pyx_n_u_load);
+3270: if todo=='dump':
__Pyx_TraceLine(3270,0,__PYX_ERR(0, 3270, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dump, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3270, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+3271: yml_fn = get_config_fname_from_varname(data, yml_fn)
__Pyx_TraceLine(3271,0,__PYX_ERR(0, 3271, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_get_config_fname_from_varname); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_data, __pyx_v_yml_fn}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 3271, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_yml_fn, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+3272: try :
__Pyx_TraceLine(3272,0,__PYX_ERR(0, 3272, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L13_try_end; __pyx_L8_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L10_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L13_try_end:; }
+3273: if todo=='load':
__Pyx_TraceLine(3273,0,__PYX_ERR(0, 3273, __pyx_L8_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_load, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3273, __pyx_L8_error) if (__pyx_t_7) { /* … */ goto __pyx_L14; }
+3274: with open(yml_fn) as fy:
__Pyx_TraceLine(3274,0,__PYX_ERR(0, 3274, __pyx_L8_error)) /*with:*/ { __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_open, __pyx_v_yml_fn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3274, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3274, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_n_s_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3274, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3274, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*try:*/ { { /*try:*/ { __pyx_v_fy = __pyx_t_2; __pyx_t_2 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L24_try_end; __pyx_L19_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_yaml", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 3274, __pyx_L21_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_Pack(3, __pyx_t_15, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3274, __pyx_L21_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3274, __pyx_L21_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_16); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_7 < 0) __PYX_ERR(0, 3274, __pyx_L21_except_error) __pyx_t_17 = (!__pyx_t_7); if (unlikely(__pyx_t_17)) { __Pyx_GIVEREF(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_ErrRestoreWithState(__pyx_t_15, __pyx_t_3, __pyx_t_2); __pyx_t_15 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0; __PYX_ERR(0, 3274, __pyx_L21_except_error) } __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L20_exception_handled; } __pyx_L21_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); goto __pyx_L8_error; __pyx_L20_exception_handled:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_L24_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_11) { __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3274, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } goto __pyx_L18; } __pyx_L18:; } goto __pyx_L28; __pyx_L15_error:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L8_error; __pyx_L28:; }
+3275: data = yaml.load(fy, Loader=yaml.SafeLoader)
__Pyx_TraceLine(3275,0,__PYX_ERR(0, 3275, __pyx_L19_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_yaml); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_load); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_fy); __Pyx_GIVEREF(__pyx_v_fy); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fy)) __PYX_ERR(0, 3275, __pyx_L19_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_yaml); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_SafeLoader); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_Loader, __pyx_t_15) < 0) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3275, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_15); __pyx_t_15 = 0;
3276: # args =yaml.safe_load(fy)
+3277: elif todo =='dump':
__Pyx_TraceLine(3277,0,__PYX_ERR(0, 3277, __pyx_L8_error)) __pyx_t_17 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dump, Py_EQ)); if (unlikely((__pyx_t_17 < 0))) __PYX_ERR(0, 3277, __pyx_L8_error) if (__pyx_t_17) { /* … */ } __pyx_L14:;
3278:
+3279: with open(f'{yml_fn}.yml', 'w') as fw:
__Pyx_TraceLine(3279,0,__PYX_ERR(0, 3279, __pyx_L8_error)) /*with:*/ { __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_yml_fn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3279, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_yml); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3279, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3279, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3)) __PYX_ERR(0, 3279, __pyx_L8_error); __Pyx_INCREF(__pyx_n_u_w); __Pyx_GIVEREF(__pyx_n_u_w); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_n_u_w)) __PYX_ERR(0, 3279, __pyx_L8_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_open, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3279, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3279, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3279, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3279, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_15 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __pyx_v_fw = __pyx_t_15; __pyx_t_15 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L38_try_end; __pyx_L33_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_yaml", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_15) < 0) __PYX_ERR(0, 3279, __pyx_L35_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_15); __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_2, __pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3279, __pyx_L35_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3279, __pyx_L35_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_t_16); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_17 < 0) __PYX_ERR(0, 3279, __pyx_L35_except_error) __pyx_t_7 = (!__pyx_t_17); if (unlikely(__pyx_t_7)) { __Pyx_GIVEREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_2, __pyx_t_15); __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_15 = 0; __PYX_ERR(0, 3279, __pyx_L35_except_error) } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L34_exception_handled; } __pyx_L35_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); goto __pyx_L8_error; __pyx_L34_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12); __pyx_L38_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_11) { __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3279, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } goto __pyx_L32; } __pyx_L32:; } goto __pyx_L42; __pyx_L29_error:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L8_error; __pyx_L42:; }
+3280: data = yaml.dump(data, fw, **ymlkws)
__Pyx_TraceLine(3280,0,__PYX_ERR(0, 3280, __pyx_L33_error)) __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_n_s_yaml); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3280, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_dump); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3280, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3280, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_data)) __PYX_ERR(0, 3280, __pyx_L33_error); __Pyx_INCREF(__pyx_v_fw); __Pyx_GIVEREF(__pyx_v_fw); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_fw)) __PYX_ERR(0, 3280, __pyx_L33_error); __pyx_t_2 = PyDict_Copy(__pyx_v_ymlkws); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3280, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_15, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3280, __pyx_L33_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+3281: except yaml.YAMLError:
__Pyx_TraceLine(3281,0,__PYX_ERR(0, 3281, __pyx_L10_except_error)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_2, &__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_yaml); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3281, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_YAMLError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3281, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_15, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_ErrRestore(__pyx_t_15, __pyx_t_2, __pyx_t_1); __pyx_t_15 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; if (__pyx_t_4) { __Pyx_AddTraceback("gofast.tools.coreutils.parse_yaml", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_15) < 0) __PYX_ERR(0, 3281, __pyx_L10_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_15);
+3282: raise yaml.YAMLError(f"Unable {domsg} YAML {yml_fn!r} file. "
__Pyx_TraceLine(3282,0,__PYX_ERR(0, 3282, __pyx_L10_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_yaml); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_YAMLError); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_19 = 0; __pyx_t_20 = 127; __Pyx_INCREF(__pyx_kp_u_Unable); __pyx_t_19 += 7; __Pyx_GIVEREF(__pyx_kp_u_Unable); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Unable); __pyx_t_21 = __Pyx_PyObject_FormatSimple(__pyx_v_domsg, __pyx_empty_unicode); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u_YAML); __pyx_t_19 += 6; __Pyx_GIVEREF(__pyx_kp_u_YAML); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_YAML); __pyx_t_21 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_yml_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_21); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u_file_Please_check_your_file); __pyx_t_19 += 30; __Pyx_GIVEREF(__pyx_kp_u_file_Please_check_your_file); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u_file_Please_check_your_file); __pyx_t_21 = __Pyx_PyUnicode_Join(__pyx_t_3, 5, __pyx_t_19, __pyx_t_20); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_21}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3282, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 3282, __pyx_L10_except_error) }
3283: 'Please check your file.')
+3284: except:
__Pyx_TraceLine(3284,0,__PYX_ERR(0, 3284, __pyx_L10_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parse_yaml", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 3284, __pyx_L10_except_error) __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_1);
+3285: msg =''.join([
__Pyx_TraceLine(3285,0,__PYX_ERR(0, 3285, __pyx_L10_except_error)) __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3285, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_18); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_18)) __PYX_ERR(0, 3285, __pyx_L10_except_error); __pyx_t_18 = 0; __pyx_t_18 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_5); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3285, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_18); __pyx_t_18 = 0;
+3286: f"{'Unrecognizable file' if todo=='load'else'Unable to serialize'}"
__Pyx_TraceLine(3286,0,__PYX_ERR(0, 3286, __pyx_L10_except_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_load, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3286, __pyx_L10_except_error) if (__pyx_t_7) { __Pyx_INCREF(__pyx_kp_u_Unrecognizable_file); __pyx_t_5 = __pyx_kp_u_Unrecognizable_file; } else { __Pyx_INCREF(__pyx_kp_u_Unable_to_serialize); __pyx_t_5 = __pyx_kp_u_Unable_to_serialize; } __pyx_t_18 = __Pyx_PyUnicode_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3286, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3287: ])
3288:
+3289: raise TypeError(f'{msg} {yml_fn!r}. Please check your'
__Pyx_TraceLine(3289,0,__PYX_ERR(0, 3289, __pyx_L10_except_error)) __pyx_t_18 = PyTuple_New(6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3289, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_19 = 0; __pyx_t_20 = 127; __pyx_t_5 = __Pyx_PyUnicode_Unicode(__pyx_v_msg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3289, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_19 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_18, 1, __pyx_kp_u__14); __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_yml_fn), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3289, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_18, 2, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_Please_check_your); __pyx_t_19 += 20; __Pyx_GIVEREF(__pyx_kp_u_Please_check_your); PyTuple_SET_ITEM(__pyx_t_18, 3, __pyx_kp_u_Please_check_your); /* … */ __Pyx_TraceLine(3289,0,__PYX_ERR(0, 3289, __pyx_L10_except_error)) __pyx_t_21 = __Pyx_PyUnicode_Join(__pyx_t_18, 6, __pyx_t_19, __pyx_t_20); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3289, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_21); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3289, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0; __Pyx_Raise(__pyx_t_18, 0, 0, 0); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __PYX_ERR(0, 3289, __pyx_L10_except_error) }
+3290: f" {'file' if todo=='load' else 'data'}.")
__Pyx_TraceLine(3290,0,__PYX_ERR(0, 3290, __pyx_L10_except_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_load, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 3290, __pyx_L10_except_error) if (__pyx_t_7) { __Pyx_INCREF(__pyx_n_u_file); __pyx_t_5 = __pyx_n_u_file; } else { __Pyx_INCREF(__pyx_n_u_data); __pyx_t_5 = __pyx_n_u_data; } __pyx_t_21 = __Pyx_PyUnicode_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3290, __pyx_L10_except_error) __Pyx_GOTREF(__pyx_t_21); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_20 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) > __pyx_t_20) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_21) : __pyx_t_20; __pyx_t_19 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_21); __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_18, 4, __pyx_t_21); __pyx_t_21 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_19 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_18, 5, __pyx_kp_u__26);
3291:
+3292: cparser_manager(f'{yml_fn}.yml',savepath, todo=todo, dpath='_saveyaml_',
__Pyx_TraceLine(3292,0,__PYX_ERR(0, 3292, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cparser_manager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_yml_fn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_yml); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_15); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_15)) __PYX_ERR(0, 3292, __pyx_L1_error); __Pyx_INCREF(__pyx_v_savepath); __Pyx_GIVEREF(__pyx_v_savepath); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_savepath)) __PYX_ERR(0, 3292, __pyx_L1_error); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_todo, __pyx_v_todo) < 0) __PYX_ERR(0, 3292, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_dpath, __pyx_n_u_saveyaml) < 0) __PYX_ERR(0, 3292, __pyx_L1_error) /* … */ __Pyx_TraceLine(3292,0,__PYX_ERR(0, 3292, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_15); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
+3293: verbose=verbose , config='YAML' )
__Pyx_TraceLine(3293,0,__PYX_ERR(0, 3293, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_verbose, __pyx_v_verbose) < 0) __PYX_ERR(0, 3292, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_15, __pyx_n_s_config, __pyx_n_u_YAML_2) < 0) __PYX_ERR(0, 3292, __pyx_L1_error)
3294:
+3295: return data
__Pyx_TraceLine(3295,0,__PYX_ERR(0, 3295, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
3296:
+3297: def cparser_manager (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_122cparser_manager(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_121cparser_manager, " Save and output message according to the action. \n \n :param cfile: name of the configuration file\n :param savepath: Path-like object \n :param dpath: default path \n :param todo: Action to perform with config file. Can ve \n ``load`` or ``dump``\n :param config: Type of configuration file. Can be ['YAML|CSV|JSON]\n :param verbose: int, control the verbosity. Output messages\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_122cparser_manager = {"cparser_manager", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_122cparser_manager, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_121cparser_manager}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_122cparser_manager(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_cfile = 0; PyObject *__pyx_v_savepath = 0; PyObject *__pyx_v_todo = 0; PyObject *__pyx_v_dpath = 0; PyObject *__pyx_v_verbose = 0; PyObject *__pyx_v_pkws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cparser_manager (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_pkws = PyDict_New(); if (unlikely(!__pyx_v_pkws)) return NULL; __Pyx_GOTREF(__pyx_v_pkws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cfile,&__pyx_n_s_savepath,&__pyx_n_s_todo,&__pyx_n_s_dpath,&__pyx_n_s_verbose,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_pkws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_121cparser_manager(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cfile, PyObject *__pyx_v_savepath, PyObject *__pyx_v_todo, PyObject *__pyx_v_dpath, PyObject *__pyx_v_verbose, PyObject *__pyx_v_pkws) { PyObject *__pyx_v_yml_fn = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__163) __Pyx_TraceCall("cparser_manager", __pyx_f[0], 3297, 0, __PYX_ERR(0, 3297, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_savepath); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.cparser_manager", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_yml_fn); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_savepath); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__432 = PyTuple_Pack(8, __pyx_n_s_cfile, __pyx_n_s_savepath, __pyx_n_s_todo, __pyx_n_s_dpath, __pyx_n_s_verbose, __pyx_n_s_pkws, __pyx_n_s_yml_fn, __pyx_n_s__8); if (unlikely(!__pyx_tuple__432)) __PYX_ERR(0, 3297, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__432); __Pyx_GIVEREF(__pyx_tuple__432); __pyx_codeobj__163 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__432, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_cparser_manager, 3297, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__163)) __PYX_ERR(0, 3297, __pyx_L1_error) /* … */ __Pyx_TraceLine(3297,0,__PYX_ERR(0, 3297, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_todo, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3297, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_122cparser_manager, 0, __pyx_n_s_cparser_manager, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__163)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3297, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__433); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_cparser_manager, __pyx_t_2) < 0) __PYX_ERR(0, 3297, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__433 = PyTuple_Pack(4, Py_None, ((PyObject*)__pyx_n_u_load), Py_None, ((PyObject *)__pyx_int_0)); if (unlikely(!__pyx_tuple__433)) __PYX_ERR(0, 3297, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__433); __Pyx_GIVEREF(__pyx_tuple__433);
3298: cfile,
+3299: savepath =None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_load)));
3300: todo:str ='load',
+3301: dpath=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cfile)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3297, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3297, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3297, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dpath); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3297, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3297, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_pkws, values + 0, kwd_pos_args, "cparser_manager") < 0)) __PYX_ERR(0, 3297, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_cfile = values[0]; __pyx_v_savepath = values[1]; __pyx_v_todo = ((PyObject*)values[2]); __pyx_v_dpath = values[3]; __pyx_v_verbose = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cparser_manager", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 3297, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_pkws); __pyx_v_pkws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.cparser_manager", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_todo), (&PyUnicode_Type), 0, "todo", 1))) __PYX_ERR(0, 3300, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_121cparser_manager(__pyx_self, __pyx_v_cfile, __pyx_v_savepath, __pyx_v_todo, __pyx_v_dpath, __pyx_v_verbose, __pyx_v_pkws);
3302: verbose =0,
3303: **pkws):
3304: """ Save and output message according to the action.
3305:
3306: :param cfile: name of the configuration file
3307: :param savepath: Path-like object
3308: :param dpath: default path
3309: :param todo: Action to perform with config file. Can ve
3310: ``load`` or ``dump``
3311: :param config: Type of configuration file. Can be ['YAML|CSV|JSON]
3312: :param verbose: int, control the verbosity. Output messages
3313:
3314: """
+3315: if savepath is not None:
__Pyx_TraceLine(3315,0,__PYX_ERR(0, 3315, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_savepath != Py_None); if (__pyx_t_1) { /* … */ }
+3316: if savepath =='default':
__Pyx_TraceLine(3316,0,__PYX_ERR(0, 3316, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_savepath, __pyx_n_u_default, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3316, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+3317: savepath = None
__Pyx_TraceLine(3317,0,__PYX_ERR(0, 3317, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_savepath, Py_None);
+3318: yml_fn,_= move_cfile(cfile, savepath, dpath=dpath)
__Pyx_TraceLine(3318,0,__PYX_ERR(0, 3318, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_move_cfile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_cfile); __Pyx_GIVEREF(__pyx_v_cfile); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_cfile)) __PYX_ERR(0, 3318, __pyx_L1_error); __Pyx_INCREF(__pyx_v_savepath); __Pyx_GIVEREF(__pyx_v_savepath); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_savepath)) __PYX_ERR(0, 3318, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dpath, __pyx_v_dpath) < 0) __PYX_ERR(0, 3318, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3318, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); index = 0; __pyx_t_4 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_2), 2) < 0) __PYX_ERR(0, 3318, __pyx_L1_error) __pyx_t_6 = NULL; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3318, __pyx_L1_error) __pyx_L6_unpacking_done:; } __pyx_v_yml_fn = __pyx_t_4; __pyx_t_4 = 0; __pyx_v__ = __pyx_t_3; __pyx_t_3 = 0;
+3319: if verbose > 0:
__Pyx_TraceLine(3319,0,__PYX_ERR(0, 3319, __pyx_L1_error)) __pyx_t_5 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3319, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3319, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_1) { /* … */ }
+3320: print_cmsg(yml_fn, todo, **pkws)
__Pyx_TraceLine(3320,0,__PYX_ERR(0, 3320, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_print_cmsg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(!__pyx_v_yml_fn)) { __Pyx_RaiseUnboundLocalError("yml_fn"); __PYX_ERR(0, 3320, __pyx_L1_error) } __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_yml_fn); __Pyx_GIVEREF(__pyx_v_yml_fn); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_yml_fn)) __PYX_ERR(0, 3320, __pyx_L1_error); __Pyx_INCREF(__pyx_v_todo); __Pyx_GIVEREF(__pyx_v_todo); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_todo)) __PYX_ERR(0, 3320, __pyx_L1_error); __pyx_t_4 = PyDict_Copy(__pyx_v_pkws); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3320, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3321:
3322:
+3323: def get_config_fname_from_varname(data,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_124get_config_fname_from_varname(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_123get_config_fname_from_varname, " use the variable name given to data as the config file name.\n \n :param data: Given data to retrieve the variable name \n :param config_fname: Configurate variable filename. If ``None`` , use \n the name of the given varibale data \n :param config: Type of file for configuration. Can be ``json``, ``yml`` \n or ``csv`` file. default is ``yml``.\n :return: str, the configuration data.\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_124get_config_fname_from_varname = {"get_config_fname_from_varname", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_124get_config_fname_from_varname, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_123get_config_fname_from_varname}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_124get_config_fname_from_varname(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_config_fname = 0; PyObject *__pyx_v_config = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_config_fname_from_varname (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_config_fname,&__pyx_n_s_config,0}; PyObject* values[3] = {0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_123get_config_fname_from_varname(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_config_fname, PyObject *__pyx_v_config) { PyObject *__pyx_v_c = NULL; PyObject *__pyx_v_n = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__164) __Pyx_TraceCall("get_config_fname_from_varname", __pyx_f[0], 3323, 0, __PYX_ERR(0, 3323, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_config_fname); __Pyx_INCREF(__pyx_v_config); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.get_config_fname_from_varname", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_c); __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_v_config_fname); __Pyx_XDECREF(__pyx_v_config); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__434 = PyTuple_Pack(5, __pyx_n_s_data, __pyx_n_s_config_fname, __pyx_n_s_config, __pyx_n_s_c_2, __pyx_n_s_n); if (unlikely(!__pyx_tuple__434)) __PYX_ERR(0, 3323, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__434); __Pyx_GIVEREF(__pyx_tuple__434); __pyx_codeobj__164 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__434, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_config_fname_from_varname, 3323, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__164)) __PYX_ERR(0, 3323, __pyx_L1_error) /* … */ __Pyx_TraceLine(3323,0,__PYX_ERR(0, 3323, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3323, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_124get_config_fname_from_varname, 0, __pyx_n_s_get_config_fname_from_varname, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__164)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__435); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_config_fname_from_varname, __pyx_t_4) < 0) __PYX_ERR(0, 3323, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__435 = PyTuple_Pack(2, Py_None, ((PyObject*)__pyx_kp_u_yml)); if (unlikely(!__pyx_tuple__435)) __PYX_ERR(0, 3323, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__435); __Pyx_GIVEREF(__pyx_tuple__435);
+3324: config_fname=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u_yml))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3323, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_config_fname); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3323, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_config); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3323, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_config_fname_from_varname") < 0)) __PYX_ERR(0, 3323, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_config_fname = values[1]; __pyx_v_config = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_config_fname_from_varname", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 3323, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_config_fname_from_varname", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_123get_config_fname_from_varname(__pyx_self, __pyx_v_data, __pyx_v_config_fname, __pyx_v_config);
3325: config='.yml') -> str:
3326: """ use the variable name given to data as the config file name.
3327:
3328: :param data: Given data to retrieve the variable name
3329: :param config_fname: Configurate variable filename. If ``None`` , use
3330: the name of the given varibale data
3331: :param config: Type of file for configuration. Can be ``json``, ``yml``
3332: or ``csv`` file. default is ``yml``.
3333: :return: str, the configuration data.
3334:
3335: """
+3336: try:
__Pyx_TraceLine(3336,0,__PYX_ERR(0, 3336, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_L8_try_end:; }
+3337: if '.' in config:
__Pyx_TraceLine(3337,0,__PYX_ERR(0, 3337, __pyx_L3_error)) __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__26, __pyx_v_config, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3337, __pyx_L3_error) if (__pyx_t_4) { /* … */ }
+3338: config =config.replace('.','')
__Pyx_TraceLine(3338,0,__PYX_ERR(0, 3338, __pyx_L3_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_config, __pyx_n_s_replace); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3338, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__165, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3338, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_config, __pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_tuple__165 = PyTuple_Pack(2, __pyx_kp_u__26, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__165)) __PYX_ERR(0, 3338, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__165); __Pyx_GIVEREF(__pyx_tuple__165);
+3339: except:pass # in the case None is given
__Pyx_TraceLine(3339,0,__PYX_ERR(0, 3339, __pyx_L5_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; }
3340:
+3341: if config_fname is None: # get the varname
__Pyx_TraceLine(3341,0,__PYX_ERR(0, 3341, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_config_fname == Py_None); if (__pyx_t_4) { /* … */ goto __pyx_L10; }
3342: # try :
3343: # from varname.helpers import Wrapper
3344: # except ImportError:
3345: # import_varname=False
3346: # import_varname = FU.subprocess_module_installation('varname')
3347: # if import_varname:
3348: # from varname.helpers import Wrapper
3349: # else : import_varname=True
+3350: try :
__Pyx_TraceLine(3350,0,__PYX_ERR(0, 3350, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L16_try_end; __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1); goto __pyx_L1_error; __pyx_L12_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_2, __pyx_t_1); __pyx_L16_try_end:; }
+3351: for c, n in zip(['yml', 'yaml', 'json', 'csv'],
__Pyx_TraceLine(3351,0,__PYX_ERR(0, 3351, __pyx_L11_error)) __pyx_t_6 = PyList_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_n_u_yml_2); __Pyx_GIVEREF(__pyx_n_u_yml_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_yml_2)) __PYX_ERR(0, 3351, __pyx_L11_error); __Pyx_INCREF(__pyx_n_u_yaml); __Pyx_GIVEREF(__pyx_n_u_yaml); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_yaml)) __PYX_ERR(0, 3351, __pyx_L11_error); __Pyx_INCREF(__pyx_n_u_json_2); __Pyx_GIVEREF(__pyx_n_u_json_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 2, __pyx_n_u_json_2)) __PYX_ERR(0, 3351, __pyx_L11_error); __Pyx_INCREF(__pyx_n_u_csv); __Pyx_GIVEREF(__pyx_n_u_csv); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 3, __pyx_n_u_csv)) __PYX_ERR(0, 3351, __pyx_L11_error); /* … */ __Pyx_TraceLine(3351,0,__PYX_ERR(0, 3351, __pyx_L11_error)) __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6)) __PYX_ERR(0, 3351, __pyx_L11_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5)) __PYX_ERR(0, 3351, __pyx_L11_error); __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_7 = __pyx_t_5; __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3351, __pyx_L11_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3351, __pyx_L11_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 3351, __pyx_L11_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3351, __pyx_L11_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 3351, __pyx_L11_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_9(__pyx_t_7); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 3351, __pyx_L11_error) } break; } __Pyx_GOTREF(__pyx_t_5); } if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3351, __pyx_L11_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_10 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_10); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_10); #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3351, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_12 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); index = 0; __pyx_t_6 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_6)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) __PYX_ERR(0, 3351, __pyx_L11_error) __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L20_unpacking_done; __pyx_L19_unpacking_failed:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3351, __pyx_L11_error) __pyx_L20_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_n, __pyx_t_10); __pyx_t_10 = 0; /* … */ __Pyx_TraceLine(3351,0,__PYX_ERR(0, 3351, __pyx_L11_error)) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L22_for_end; __pyx_L18_break:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L22_for_end; __pyx_L22_for_end:;
+3352: ['cy.data', 'cy.data', 'cj.data',
__Pyx_TraceLine(3352,0,__PYX_ERR(0, 3352, __pyx_L11_error)) __pyx_t_5 = PyList_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3352, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_kp_u_cy_data); __Pyx_GIVEREF(__pyx_kp_u_cy_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_cy_data)) __PYX_ERR(0, 3352, __pyx_L11_error); __Pyx_INCREF(__pyx_kp_u_cy_data); __Pyx_GIVEREF(__pyx_kp_u_cy_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 1, __pyx_kp_u_cy_data)) __PYX_ERR(0, 3352, __pyx_L11_error); __Pyx_INCREF(__pyx_kp_u_cj_data); __Pyx_GIVEREF(__pyx_kp_u_cj_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_cj_data)) __PYX_ERR(0, 3352, __pyx_L11_error); __Pyx_INCREF(__pyx_kp_u_c_data); __Pyx_GIVEREF(__pyx_kp_u_c_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 3, __pyx_kp_u_c_data)) __PYX_ERR(0, 3352, __pyx_L11_error);
3353: 'c.data']):
+3354: if config ==c:
__Pyx_TraceLine(3354,0,__PYX_ERR(0, 3354, __pyx_L11_error)) __pyx_t_5 = PyObject_RichCompare(__pyx_v_config, __pyx_v_c, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3354, __pyx_L11_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3354, __pyx_L11_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_4) { /* … */ }
+3355: config_fname= n
__Pyx_TraceLine(3355,0,__PYX_ERR(0, 3355, __pyx_L11_error)) __Pyx_INCREF(__pyx_v_n); __Pyx_DECREF_SET(__pyx_v_config_fname, __pyx_v_n);
+3356: break
__Pyx_TraceLine(3356,0,__PYX_ERR(0, 3356, __pyx_L11_error)) goto __pyx_L18_break;
+3357: if config_fname is None:
__Pyx_TraceLine(3357,0,__PYX_ERR(0, 3357, __pyx_L11_error)) __pyx_t_4 = (__pyx_v_config_fname == Py_None); if (unlikely(__pyx_t_4)) { /* … */ }
+3358: raise # and go to except
__Pyx_TraceLine(3358,0,__PYX_ERR(0, 3358, __pyx_L11_error)) __Pyx_ReraiseException(); __PYX_ERR(0, 3358, __pyx_L11_error)
+3359: except:
__Pyx_TraceLine(3359,0,__PYX_ERR(0, 3359, __pyx_L13_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.get_config_fname_from_varname", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 3359, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_10);
3360: #using fstring
+3361: config_fname= f'{data}'.split('=')[0]
__Pyx_TraceLine(3361,0,__PYX_ERR(0, 3361, __pyx_L13_except_error)) __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v_data, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3361, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = PyUnicode_Split(((PyObject*)__pyx_t_6), __Pyx_NoneAsNull(__pyx_kp_u__54), -1L); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3361, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_t_11, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3361, __pyx_L13_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF_SET(__pyx_v_config_fname, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L12_exception_handled; }
3362:
+3363: elif config_fname is not None:
__Pyx_TraceLine(3363,0,__PYX_ERR(0, 3363, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_config_fname != Py_None); if (__pyx_t_4) { /* … */ } __pyx_L10:;
+3364: config_fname= config_fname.replace(
__Pyx_TraceLine(3364,0,__PYX_ERR(0, 3364, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_config_fname, __pyx_n_s_replace); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7);
+3365: f'.{config}', '').replace(f'.{config}', '').replace('.yaml', '')
__Pyx_TraceLine(3365,0,__PYX_ERR(0, 3365, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v_config, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = __Pyx_PyUnicode_Concat(__pyx_kp_u__26, __pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_11, __pyx_kp_u__22}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_13, 2+__pyx_t_13); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3364, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_replace); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_config, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = __Pyx_PyUnicode_Concat(__pyx_kp_u__26, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_11, __pyx_kp_u__22}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_13, 2+__pyx_t_13); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_replace); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__166, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF_SET(__pyx_v_config_fname, __pyx_t_10); __pyx_t_10 = 0; /* … */ __pyx_tuple__166 = PyTuple_Pack(2, __pyx_kp_u_yaml_2, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__166)) __PYX_ERR(0, 3365, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__166); __Pyx_GIVEREF(__pyx_tuple__166);
3366:
+3367: return config_fname
__Pyx_TraceLine(3367,0,__PYX_ERR(0, 3367, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (!(likely(PyUnicode_CheckExact(__pyx_v_config_fname))||((__pyx_v_config_fname) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_config_fname))) __PYX_ERR(0, 3367, __pyx_L1_error) __Pyx_INCREF(__pyx_v_config_fname); __pyx_r = ((PyObject*)__pyx_v_config_fname); goto __pyx_L0;
3368:
+3369: def pretty_printer(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_126pretty_printer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_125pretty_printer, " Format and pretty print messages after gridSearch using multiples\n estimators.\n \n Display for each estimator, its name, it best params with higher score \n and the mean scores. \n \n Parameters\n ----------\n clfs:Callables \n classifiers or estimators \n \n clf_scores: array-like\n for single classifier, usefull to provided the \n cross validation score.\n \n scoring: str \n Scoring used for grid search.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_126pretty_printer = {"pretty_printer", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_126pretty_printer, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_125pretty_printer}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_126pretty_printer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_clfs = 0; PyObject *__pyx_v_clf_score = 0; PyObject *__pyx_v_scoring = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("pretty_printer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_clfs,&__pyx_n_s_clf_score,&__pyx_n_s_scoring,0}; PyObject* values[3] = {0,0,0}; /* … */ /* function exit code */ __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_125pretty_printer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_clfs, PyObject *__pyx_v_clf_score, PyObject *__pyx_v_scoring, PyObject *__pyx_v_kws) { PyObject *__pyx_v_empty = NULL; PyObject *__pyx_v_e_pad = NULL; PyObject *__pyx_v_p = NULL; PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_clf = NULL; PyObject *__pyx_v_clf_be = NULL; PyObject *__pyx_v_clf_bp = NULL; PyObject *__pyx_v_clf_sc = NULL; PyObject *__pyx_v_s_ = NULL; PyObject *__pyx_v_s0 = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__167) __Pyx_TraceCall("pretty_printer", __pyx_f[0], 3369, 0, __PYX_ERR(0, 3369, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_clfs); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("gofast.tools.coreutils.pretty_printer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_empty); __Pyx_XDECREF(__pyx_v_e_pad); __Pyx_XDECREF(__pyx_v_p); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_clf); __Pyx_XDECREF(__pyx_v_clf_be); __Pyx_XDECREF(__pyx_v_clf_bp); __Pyx_XDECREF(__pyx_v_clf_sc); __Pyx_XDECREF(__pyx_v_s_); __Pyx_XDECREF(__pyx_v_s0); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_clfs); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__436 = PyTuple_Pack(15, __pyx_n_s_clfs, __pyx_n_s_clf_score, __pyx_n_s_scoring, __pyx_n_s_kws_2, __pyx_n_s_empty, __pyx_n_s_e_pad, __pyx_n_s_p, __pyx_n_s_ii, __pyx_n_s_clf, __pyx_n_s_clf_be, __pyx_n_s_clf_bp, __pyx_n_s_clf_sc, __pyx_n_s_s_5, __pyx_n_s_s0, __pyx_n_s_i); if (unlikely(!__pyx_tuple__436)) __PYX_ERR(0, 3369, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__436); __Pyx_GIVEREF(__pyx_tuple__436); /* … */ __Pyx_TraceLine(3369,0,__PYX_ERR(0, 3369, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_clfs, __pyx_kp_s_List__F) < 0) __PYX_ERR(0, 3369, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_clf_score, __pyx_kp_s_List_float) < 0) __PYX_ERR(0, 3369, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_scoring, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 3369, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_None) < 0) __PYX_ERR(0, 3369, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_126pretty_printer, 0, __pyx_n_s_pretty_printer, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__167)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__226); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_pretty_printer, __pyx_t_2) < 0) __PYX_ERR(0, 3369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__167 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__436, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_pretty_printer, 3369, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__167)) __PYX_ERR(0, 3369, __pyx_L1_error)
3370: clfs: List[_F],
+3371: clf_score:List[float]=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+3372: scoring: Optional[str] =None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_clfs)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3369, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_clf_score); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3369, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_scoring); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3369, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "pretty_printer") < 0)) __PYX_ERR(0, 3369, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_clfs = values[0]; __pyx_v_clf_score = values[1]; __pyx_v_scoring = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("pretty_printer", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 3369, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.pretty_printer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_125pretty_printer(__pyx_self, __pyx_v_clfs, __pyx_v_clf_score, __pyx_v_scoring, __pyx_v_kws);
3373: **kws
3374: )->None:
3375: """ Format and pretty print messages after gridSearch using multiples
3376: estimators.
3377:
3378: Display for each estimator, its name, it best params with higher score
3379: and the mean scores.
3380:
3381: Parameters
3382: ----------
3383: clfs:Callables
3384: classifiers or estimators
3385:
3386: clf_scores: array-like
3387: for single classifier, usefull to provided the
3388: cross validation score.
3389:
3390: scoring: str
3391: Scoring used for grid search.
3392: """
+3393: empty =kws.pop('empty', ' ')
__Pyx_TraceLine(3393,0,__PYX_ERR(0, 3393, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_empty, __pyx_kp_u__14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_empty = __pyx_t_1; __pyx_t_1 = 0;
+3394: e_pad =kws.pop('e_pad', 2)
__Pyx_TraceLine(3394,0,__PYX_ERR(0, 3394, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Pop(__pyx_v_kws, __pyx_n_u_e_pad, __pyx_int_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_e_pad = __pyx_t_1; __pyx_t_1 = 0;
+3395: p=list()
__Pyx_TraceLine(3395,0,__PYX_ERR(0, 3395, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_p = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
3396:
+3397: if not isinstance(clfs, (list,tuple)):
__Pyx_TraceLine(3397,0,__PYX_ERR(0, 3397, __pyx_L1_error)) __pyx_t_3 = PyList_Check(__pyx_v_clfs); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_clfs); __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { /* … */ }
+3398: clfs =(clfs, clf_score)
__Pyx_TraceLine(3398,0,__PYX_ERR(0, 3398, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_clfs); __Pyx_GIVEREF(__pyx_v_clfs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_clfs)) __PYX_ERR(0, 3398, __pyx_L1_error); __Pyx_INCREF(__pyx_v_clf_score); __Pyx_GIVEREF(__pyx_v_clf_score); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_clf_score)) __PYX_ERR(0, 3398, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_clfs, __pyx_t_1); __pyx_t_1 = 0;
3399:
+3400: for ii, (clf, clf_be, clf_bp, clf_sc) in enumerate(clfs):
__Pyx_TraceLine(3400,0,__PYX_ERR(0, 3400, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_clfs)) || PyTuple_CheckExact(__pyx_v_clfs)) { __pyx_t_4 = __pyx_v_clfs; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_clfs); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3400, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3400, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 3400, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3400, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 3400, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 3400, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) { PyObject* sequence = __pyx_t_7; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 3400, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_8 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); __pyx_t_10 = PyList_GET_ITEM(sequence, 2); __pyx_t_11 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 3400, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11}; __pyx_t_12 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_13(__pyx_t_12); if (unlikely(!item)) goto __pyx_L8_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 4) < 0) __PYX_ERR(0, 3400, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L9_unpacking_done; __pyx_L8_unpacking_failed:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 3400, __pyx_L1_error) __pyx_L9_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_clf, __pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_clf_be, __pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_clf_bp, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_clf_sc, __pyx_t_11); __pyx_t_11 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_1); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3400, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(3400,0,__PYX_ERR(0, 3400, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+3401: s_=[e_pad* empty + '{:<20}:'.format(
__Pyx_TraceLine(3401,0,__PYX_ERR(0, 3401, __pyx_L1_error)) __pyx_t_7 = PyNumber_Multiply(__pyx_v_e_pad, __pyx_v_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); /* … */ __Pyx_TraceLine(3401,0,__PYX_ERR(0, 3401, __pyx_L1_error)) __pyx_t_10 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; /* … */ __Pyx_TraceLine(3401,0,__PYX_ERR(0, 3401, __pyx_L1_error)) __pyx_t_11 = PyList_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_10); if (__Pyx_PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_10)) __PYX_ERR(0, 3401, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyList_SET_ITEM(__pyx_t_11, 1, __pyx_t_8)) __PYX_ERR(0, 3401, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyList_SET_ITEM(__pyx_t_11, 2, __pyx_t_9)) __PYX_ERR(0, 3401, __pyx_L1_error); __pyx_t_10 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __Pyx_XDECREF_SET(__pyx_v_s_, ((PyObject*)__pyx_t_11)); __pyx_t_11 = 0;
+3402: clf.__class__.__name__) + '{:<20}:'.format(
__Pyx_TraceLine(3402,0,__PYX_ERR(0, 3402, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_clf, __pyx_n_s_class); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } /* … */ __Pyx_TraceLine(3402,0,__PYX_ERR(0, 3402, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); /* … */ __Pyx_TraceLine(3402,0,__PYX_ERR(0, 3402, __pyx_L1_error)) __pyx_t_7 = PyNumber_Add(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+3403: 'Best-estimator <{}>'.format(ii+1)) +'{}'.format(clf_be),
__Pyx_TraceLine(3403,0,__PYX_ERR(0, 3403, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Best_estimator, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = __Pyx_PyInt_AddObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_12}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_8}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3402, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } /* … */ __Pyx_TraceLine(3403,0,__PYX_ERR(0, 3403, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_clf_be}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+3404: e_pad* empty +'{:<20}:'.format(' ')+ '{:<20}:'.format(
__Pyx_TraceLine(3404,0,__PYX_ERR(0, 3404, __pyx_L1_error)) __pyx_t_11 = PyNumber_Multiply(__pyx_v_e_pad, __pyx_v_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_kp_u__14}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = PyNumber_Add(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_kp_u_Best_paramaters}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = PyNumber_Add(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+3405: 'Best paramaters') + '{}'.format(clf_bp),
__Pyx_TraceLine(3405,0,__PYX_ERR(0, 3405, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_clf_bp}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = PyNumber_Add(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+3406: e_pad* empty +'{:<20}:'.format(' ') + '{:<20}:'.format(
__Pyx_TraceLine(3406,0,__PYX_ERR(0, 3406, __pyx_L1_error)) __pyx_t_7 = PyNumber_Multiply(__pyx_v_e_pad, __pyx_v_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_kp_u__14}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); /* … */ __Pyx_TraceLine(3406,0,__PYX_ERR(0, 3406, __pyx_L1_error)) __pyx_t_7 = PyNumber_Add(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+3407: 'scores<`{}`>'.format(scoring)) +'{}'.format(clf_sc)]
__Pyx_TraceLine(3407,0,__PYX_ERR(0, 3407, __pyx_L1_error)) __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_scores, __pyx_n_s_format); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_15); __pyx_t_16 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_15))) { __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_15); if (likely(__pyx_t_16)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15); __Pyx_INCREF(__pyx_t_16); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_15, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_v_scoring}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_15, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; } __pyx_t_15 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_12}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } /* … */ __Pyx_TraceLine(3407,0,__PYX_ERR(0, 3407, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_v_clf_sc}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+3408: try :
__Pyx_TraceLine(3408,0,__PYX_ERR(0, 3408, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L12_except_error:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); goto __pyx_L1_error; __pyx_L11_exception_handled:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19); __pyx_L17_try_end:; }
+3409: s0= [e_pad* empty +'{:<20}:'.format(' ')+ '{:<20}:'.format(
__Pyx_TraceLine(3409,0,__PYX_ERR(0, 3409, __pyx_L10_error)) __pyx_t_11 = PyNumber_Multiply(__pyx_v_e_pad, __pyx_v_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_10 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_kp_u__14}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = PyNumber_Add(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_kp_u_scores_mean}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = PyNumber_Add(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_TraceLine(3409,0,__PYX_ERR(0, 3409, __pyx_L10_error)) __pyx_t_9 = PyList_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3409, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_8)) __PYX_ERR(0, 3409, __pyx_L10_error); __pyx_t_8 = 0; __Pyx_XDECREF_SET(__pyx_v_s0, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0;
+3410: 'scores mean')+ '{}'.format(clf_sc.mean())]
__Pyx_TraceLine(3410,0,__PYX_ERR(0, 3410, __pyx_L10_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u__73, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3410, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_clf_sc, __pyx_n_s_mean); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3410, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_14, 0+__pyx_t_14); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3410, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_10}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3410, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = PyNumber_Add(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3410, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+3411: except AttributeError:
__Pyx_TraceLine(3411,0,__PYX_ERR(0, 3411, __pyx_L12_except_error)) __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_AttributeError); if (__pyx_t_14) { __Pyx_AddTraceback("gofast.tools.coreutils.pretty_printer", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_11) < 0) __PYX_ERR(0, 3411, __pyx_L12_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_11);
+3412: s0= [e_pad* empty +'{:<20}:'.format(' ')+ '{:<20}:'.format(
__Pyx_TraceLine(3412,0,__PYX_ERR(0, 3412, __pyx_L12_except_error)) __pyx_t_10 = PyNumber_Multiply(__pyx_v_e_pad, __pyx_v_empty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_15 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_kp_u__14}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_t_12 = PyNumber_Add(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_20, __pyx_n_s_format); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_15 = NULL; __pyx_t_14 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_15)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_15); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_14 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_kp_u_scores_mean}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_14, 1+__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = PyNumber_Add(__pyx_t_12, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(3412,0,__PYX_ERR(0, 3412, __pyx_L12_except_error)) __pyx_t_10 = PyList_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3412, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_7)) __PYX_ERR(0, 3412, __pyx_L12_except_error); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_s0, ((PyObject*)__pyx_t_10)); __pyx_t_10 = 0;
+3413: 'scores mean')+ 'None']
__Pyx_TraceLine(3413,0,__PYX_ERR(0, 3413, __pyx_L12_except_error)) __pyx_t_7 = PyNumber_Add(__pyx_t_10, __pyx_kp_u_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3413, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+3414: s_ +=s0
__Pyx_TraceLine(3414,0,__PYX_ERR(0, 3414, __pyx_L12_except_error)) __pyx_t_10 = PyNumber_InPlaceAdd(__pyx_v_s_, __pyx_v_s0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3414, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF_SET(__pyx_v_s_, ((PyObject*)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L11_exception_handled; } goto __pyx_L12_except_error;
3415: else :
+3416: s_ +=s0
__Pyx_TraceLine(3416,0,__PYX_ERR(0, 3416, __pyx_L12_except_error)) /*else:*/ { __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_v_s_, __pyx_v_s0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3416, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_s_, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0; } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0; goto __pyx_L17_try_end; __pyx_L10_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
3417:
+3418: p.extend(s_)
__Pyx_TraceLine(3418,0,__PYX_ERR(0, 3418, __pyx_L1_error)) __pyx_t_20 = __Pyx_PyList_Extend(__pyx_v_p, __pyx_v_s_); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 3418, __pyx_L1_error)
3419:
+3420: for i in p:
__Pyx_TraceLine(3420,0,__PYX_ERR(0, 3420, __pyx_L1_error)) __pyx_t_1 = __pyx_v_p; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3420, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 3420, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(3420,0,__PYX_ERR(0, 3420, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+3421: print(i)
__Pyx_TraceLine(3421,0,__PYX_ERR(0, 3421, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3421, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3422:
+3423: def move_cfile(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_128move_cfile(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_127move_cfile, "Move file to its savepath and output message.\n\n If the savepath does not exist, it will be created. If the file cannot\n be moved, it will be copied then the original will be deleted.\n\n Parameters:\n - cfile (str): Name of the file to move.\n - savepath (str, optional): Destination path for the file. If not provided \n or determined, a default provided by `cpath` is used.\n \n Returns:\n Tuple[str, str]: Updated file path and success message.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_128move_cfile = {"move_cfile", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_128move_cfile, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_127move_cfile}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_128move_cfile(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_cfile = 0; PyObject *__pyx_v_savepath = 0; PyObject *__pyx_v_ckws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("move_cfile (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_ckws = PyDict_New(); if (unlikely(!__pyx_v_ckws)) return NULL; __Pyx_GOTREF(__pyx_v_ckws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cfile,&__pyx_n_s_savepath,0}; PyObject* values[2] = {0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_ckws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_127move_cfile(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cfile, PyObject *__pyx_v_savepath, PyObject *__pyx_v_ckws) { PyObject *__pyx_v_destination_file_path = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_v_message = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__168) __Pyx_TraceCall("move_cfile", __pyx_f[0], 3423, 0, __PYX_ERR(0, 3423, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_savepath); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils.move_cfile", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_destination_file_path); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_message); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_savepath); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__437 = PyTuple_Pack(7, __pyx_n_s_cfile, __pyx_n_s_savepath, __pyx_n_s_ckws, __pyx_n_s_destination_file_path, __pyx_n_s_e, __pyx_n_s_message, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__437)) __PYX_ERR(0, 3423, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__437); __Pyx_GIVEREF(__pyx_tuple__437); /* … */ __Pyx_TraceLine(3423,0,__PYX_ERR(0, 3423, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_cfile, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3423, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_savepath, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 3423, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Tuple_str_str) < 0) __PYX_ERR(0, 3423, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_128move_cfile, 0, __pyx_n_s_move_cfile, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__168)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__62); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_move_cfile, __pyx_t_4) < 0) __PYX_ERR(0, 3423, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__168 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__437, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_move_cfile, 3423, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__168)) __PYX_ERR(0, 3423, __pyx_L1_error)
3424: cfile: str,
+3425: savepath: Optional[str] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cfile)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3423, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3423, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_ckws, values + 0, kwd_pos_args, "move_cfile") < 0)) __PYX_ERR(0, 3423, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_cfile = ((PyObject*)values[0]); __pyx_v_savepath = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("move_cfile", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 3423, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_ckws); __pyx_v_ckws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.move_cfile", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cfile), (&PyUnicode_Type), 0, "cfile", 1))) __PYX_ERR(0, 3424, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_127move_cfile(__pyx_self, __pyx_v_cfile, __pyx_v_savepath, __pyx_v_ckws);
3426: **ckws
3427: ) -> Tuple[str, str]:
3428: """Move file to its savepath and output message.
3429:
3430: If the savepath does not exist, it will be created. If the file cannot
3431: be moved, it will be copied then the original will be deleted.
3432:
3433: Parameters:
3434: - cfile (str): Name of the file to move.
3435: - savepath (str, optional): Destination path for the file. If not provided
3436: or determined, a default provided by `cpath` is used.
3437:
3438: Returns:
3439: Tuple[str, str]: Updated file path and success message.
3440: """
3441: # Assuming `cpath` function adjusts `savepath` based on `ckws`,
3442: # including default path handling
+3443: savepath = cpath(savepath, **ckws)
__Pyx_TraceLine(3443,0,__PYX_ERR(0, 3443, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_cpath); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_savepath); __Pyx_GIVEREF(__pyx_v_savepath); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_savepath)) __PYX_ERR(0, 3443, __pyx_L1_error); __pyx_t_3 = PyDict_Copy(__pyx_v_ckws); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_savepath, __pyx_t_4); __pyx_t_4 = 0;
3444:
3445: # Ensure the savepath directory exists
+3446: os.makedirs(savepath, exist_ok=True)
__Pyx_TraceLine(3446,0,__PYX_ERR(0, 3446, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_makedirs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_savepath); __Pyx_GIVEREF(__pyx_v_savepath); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_savepath)) __PYX_ERR(0, 3446, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exist_ok, Py_True) < 0) __PYX_ERR(0, 3446, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3446, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3447:
+3448: destination_file_path = os.path.join(savepath, os.path.basename(cfile))
__Pyx_TraceLine(3448,0,__PYX_ERR(0, 3448, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_join); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_cfile}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_savepath, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_destination_file_path = __pyx_t_1; __pyx_t_1 = 0;
3449:
+3450: try:
__Pyx_TraceLine(3450,0,__PYX_ERR(0, 3450, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); __pyx_L8_try_end:; }
+3451: shutil.move(cfile, destination_file_path)
__Pyx_TraceLine(3451,0,__PYX_ERR(0, 3451, __pyx_L3_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_shutil); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3451, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_move); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3451, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_cfile, __pyx_v_destination_file_path}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3451, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+3452: except shutil.Error as e:
__Pyx_TraceLine(3452,0,__PYX_ERR(0, 3452, __pyx_L5_except_error)) __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_4, &__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_shutil); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3452, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3452, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_ErrRestore(__pyx_t_1, __pyx_t_4, __pyx_t_2); __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_2 = 0; if (__pyx_t_6) { __Pyx_AddTraceback("gofast.tools.coreutils.move_cfile", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_4, &__pyx_t_1) < 0) __PYX_ERR(0, 3452, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __pyx_v_e = __pyx_t_4; /*try:*/ { /* … */ __Pyx_TraceLine(3452,0,__PYX_ERR(0, 3452, __pyx_L14_error)) /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L15; } __pyx_L14_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_6 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L5_except_error; } __pyx_L15:; } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error;
3453: # If the move is unsuccessful, copy then delete the original file
+3454: shutil.copy2(cfile, destination_file_path)
__Pyx_TraceLine(3454,0,__PYX_ERR(0, 3454, __pyx_L14_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_shutil); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3454, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3454, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_cfile, __pyx_v_destination_file_path}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3454, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+3455: os.remove(cfile)
__Pyx_TraceLine(3455,0,__PYX_ERR(0, 3455, __pyx_L14_error)) __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_os); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3455, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_remove); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3455, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_cfile}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3455, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+3456: message = (f"Warning: Could not move '{cfile}'. It was copied and the"
__Pyx_TraceLine(3456,0,__PYX_ERR(0, 3456, __pyx_L14_error)) __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3456, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Warning_Could_not_move); __pyx_t_11 += 25; __Pyx_GIVEREF(__pyx_kp_u_Warning_Could_not_move); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_kp_u_Warning_Could_not_move); __Pyx_INCREF(__pyx_v_cfile); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_cfile) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_cfile) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_cfile); __Pyx_GIVEREF(__pyx_v_cfile); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_cfile); __Pyx_INCREF(__pyx_kp_u_It_was_copied_and_the_original); __pyx_t_11 += 47; __Pyx_GIVEREF(__pyx_kp_u_It_was_copied_and_the_original); PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_kp_u_It_was_copied_and_the_original); /* … */ __Pyx_TraceLine(3456,0,__PYX_ERR(0, 3456, __pyx_L14_error)) __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_5, 4, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3456, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_message = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+3457: f" original was deleted. {e}")
__Pyx_TraceLine(3457,0,__PYX_ERR(0, 3457, __pyx_L14_error)) __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3457, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3); __pyx_t_3 = 0;
+3458: _logger.warning(message)
__Pyx_TraceLine(3458,0,__PYX_ERR(0, 3458, __pyx_L14_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3458, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_warning); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3458, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_message}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3458, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; }
3459:
+3460: msg = (f"--> '{os.path.basename(destination_file_path)}' data was successfully"
__Pyx_TraceLine(3460,0,__PYX_ERR(0, 3460, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u__169); __pyx_t_11 += 5; __Pyx_GIVEREF(__pyx_kp_u__169); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__169); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_basename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_destination_file_path}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_data_was_successfully_saved_to); __pyx_t_11 += 34; __Pyx_GIVEREF(__pyx_kp_u_data_was_successfully_saved_to); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_data_was_successfully_saved_to); /* … */ __Pyx_TraceLine(3460,0,__PYX_ERR(0, 3460, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0;
+3461: f" saved to '{os.path.realpath(destination_file_path)}'.")
__Pyx_TraceLine(3461,0,__PYX_ERR(0, 3461, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_realpath); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_destination_file_path}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__170); __pyx_t_11 += 2; __Pyx_GIVEREF(__pyx_kp_u__170); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u__170);
3462:
+3463: return destination_file_path, msg
__Pyx_TraceLine(3463,0,__PYX_ERR(0, 3463, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_destination_file_path); __Pyx_GIVEREF(__pyx_v_destination_file_path); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_destination_file_path)) __PYX_ERR(0, 3463, __pyx_L1_error); __Pyx_INCREF(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_msg)) __PYX_ERR(0, 3463, __pyx_L1_error); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
3464:
3465:
+3466: def print_cmsg(cfile:str, todo:str='load', config:str='YAML') -> str:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_130print_cmsg(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_129print_cmsg, " Output configuration message. \n \n :param cfile: name of the configuration file\n :param todo: Action to perform with config file. Can be \n ``load`` or ``dump``\n :param config: Type of configuration file. Can be [YAML|CSV|JSON]\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_130print_cmsg = {"print_cmsg", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_130print_cmsg, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_129print_cmsg}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_130print_cmsg(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_cfile = 0; PyObject *__pyx_v_todo = 0; PyObject *__pyx_v_config = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("print_cmsg (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cfile,&__pyx_n_s_todo,&__pyx_n_s_config,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_load))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_YAML_2))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cfile)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3466, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_todo); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3466, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_config); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3466, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "print_cmsg") < 0)) __PYX_ERR(0, 3466, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_cfile = ((PyObject*)values[0]); __pyx_v_todo = ((PyObject*)values[1]); __pyx_v_config = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("print_cmsg", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 3466, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.print_cmsg", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cfile), (&PyUnicode_Type), 0, "cfile", 1))) __PYX_ERR(0, 3466, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_todo), (&PyUnicode_Type), 0, "todo", 1))) __PYX_ERR(0, 3466, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_config), (&PyUnicode_Type), 0, "config", 1))) __PYX_ERR(0, 3466, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_129print_cmsg(__pyx_self, __pyx_v_cfile, __pyx_v_todo, __pyx_v_config); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_129print_cmsg(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cfile, PyObject *__pyx_v_todo, PyObject *__pyx_v_config) { PyObject *__pyx_v_msg = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__171) __Pyx_TraceCall("print_cmsg", __pyx_f[0], 3466, 0, __PYX_ERR(0, 3466, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.print_cmsg", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__438 = PyTuple_Pack(4, __pyx_n_s_cfile, __pyx_n_s_todo, __pyx_n_s_config, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__438)) __PYX_ERR(0, 3466, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__438); __Pyx_GIVEREF(__pyx_tuple__438); __pyx_codeobj__171 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__438, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_print_cmsg, 3466, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__171)) __PYX_ERR(0, 3466, __pyx_L1_error) /* … */ __Pyx_TraceLine(3466,0,__PYX_ERR(0, 3466, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_cfile, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3466, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_todo, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3466, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_config, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3466, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3466, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_130print_cmsg, 0, __pyx_n_s_print_cmsg, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__171)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__439); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_print_cmsg, __pyx_t_2) < 0) __PYX_ERR(0, 3466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__439 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u_load), ((PyObject*)__pyx_n_u_YAML_2)); if (unlikely(!__pyx_tuple__439)) __PYX_ERR(0, 3466, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__439); __Pyx_GIVEREF(__pyx_tuple__439);
3467: """ Output configuration message.
3468:
3469: :param cfile: name of the configuration file
3470: :param todo: Action to perform with config file. Can be
3471: ``load`` or ``dump``
3472: :param config: Type of configuration file. Can be [YAML|CSV|JSON]
3473: """
+3474: if todo=='load':
__Pyx_TraceLine(3474,0,__PYX_ERR(0, 3474, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_load, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3474, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+3475: msg = ''.join([
__Pyx_TraceLine(3475,0,__PYX_ERR(0, 3475, __pyx_L1_error)) __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 3475, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_8)) __PYX_ERR(0, 3475, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_8 = 0; __pyx_t_8 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_8); __pyx_t_8 = 0;
+3476: f'--> Data was successfully stored to {os.path.basename(cfile)!r}',
__Pyx_TraceLine(3476,0,__PYX_ERR(0, 3476, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_cfile}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Data_was_successfully_stored_to, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+3477: f' and saved to {os.path.realpath(cfile)!r}.']
__Pyx_TraceLine(3477,0,__PYX_ERR(0, 3477, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_and_saved_to); __pyx_t_6 += 14; __Pyx_GIVEREF(__pyx_kp_u_and_saved_to); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_and_saved_to); __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_realpath); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_cfile}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_6 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__26); __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3478: )
+3479: elif todo=='dump':
__Pyx_TraceLine(3479,0,__PYX_ERR(0, 3479, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_todo, __pyx_n_u_dump, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3479, __pyx_L1_error) if (__pyx_t_1) { /* … */ } __pyx_L3:;
+3480: msg =''.join([ f"--> {config.upper()} {os.path.basename(cfile)!r}",
__Pyx_TraceLine(3480,0,__PYX_ERR(0, 3480, __pyx_L1_error)) __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u__172); __pyx_t_6 += 4; __Pyx_GIVEREF(__pyx_kp_u__172); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_kp_u__172); __pyx_t_3 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_upper, __pyx_v_config); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_6 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u__14); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_cfile}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_data_was_sucessfully_loaded); __Pyx_GIVEREF(__pyx_kp_u_data_was_sucessfully_loaded); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 1, __pyx_kp_u_data_was_sucessfully_loaded)) __PYX_ERR(0, 3480, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3480, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
3481: " data was sucessfully loaded."])
+3482: return msg
__Pyx_TraceLine(3482,0,__PYX_ERR(0, 3482, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_msg)) { __Pyx_RaiseUnboundLocalError("msg"); __PYX_ERR(0, 3482, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_msg); __pyx_r = __pyx_v_msg; goto __pyx_L0;
3483:
3484:
+3485: def random_state_validator(seed):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_132random_state_validator(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_131random_state_validator, "Turn seed into a Numpy-Random-RandomState instance.\n \n Parameters\n ----------\n seed : None, int or instance of RandomState\n If seed is None, return the RandomState singleton used by np.random.\n If seed is an int, return a new RandomState instance seeded with seed.\n If seed is already a RandomState instance, return it.\n Otherwise raise ValueError.\n \n Returns\n -------\n :class:`numpy:numpy.random.RandomState`\n The random state object based on `seed` parameter.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_132random_state_validator = {"random_state_validator", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_132random_state_validator, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_131random_state_validator}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_132random_state_validator(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_seed = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("random_state_validator (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_seed,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_seed)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3485, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "random_state_validator") < 0)) __PYX_ERR(0, 3485, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_seed = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("random_state_validator", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 3485, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.random_state_validator", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_131random_state_validator(__pyx_self, __pyx_v_seed); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_131random_state_validator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_seed) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__173) __Pyx_TraceCall("random_state_validator", __pyx_f[0], 3485, 0, __PYX_ERR(0, 3485, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.random_state_validator", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__440 = PyTuple_Pack(1, __pyx_n_s_seed); if (unlikely(!__pyx_tuple__440)) __PYX_ERR(0, 3485, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__440); __Pyx_GIVEREF(__pyx_tuple__440); /* … */ __Pyx_TraceLine(3485,0,__PYX_ERR(0, 3485, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_132random_state_validator, 0, __pyx_n_s_random_state_validator, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__173)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_random_state_validator, __pyx_t_2) < 0) __PYX_ERR(0, 3485, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__173 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__440, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_random_state_validator, 3485, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__173)) __PYX_ERR(0, 3485, __pyx_L1_error)
3486: """Turn seed into a Numpy-Random-RandomState instance.
3487:
3488: Parameters
3489: ----------
3490: seed : None, int or instance of RandomState
3491: If seed is None, return the RandomState singleton used by np.random.
3492: If seed is an int, return a new RandomState instance seeded with seed.
3493: If seed is already a RandomState instance, return it.
3494: Otherwise raise ValueError.
3495:
3496: Returns
3497: -------
3498: :class:`numpy:numpy.random.RandomState`
3499: The random state object based on `seed` parameter.
3500: """
+3501: if seed is None or seed is np.random:
__Pyx_TraceLine(3501,0,__PYX_ERR(0, 3501, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_seed == Py_None); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = (__pyx_v_seed == __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+3502: return np.random.mtrand._rand
__Pyx_TraceLine(3502,0,__PYX_ERR(0, 3502, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_mtrand); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rand); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3502, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+3503: if isinstance(seed, numbers.Integral):
__Pyx_TraceLine(3503,0,__PYX_ERR(0, 3503, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_numbers); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Integral); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = PyObject_IsInstance(__pyx_v_seed, __pyx_t_4); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 3503, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* … */ }
+3504: return np.random.RandomState(seed)
__Pyx_TraceLine(3504,0,__PYX_ERR(0, 3504, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_RandomState); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_seed}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
+3505: if isinstance(seed, np.random.RandomState):
__Pyx_TraceLine(3505,0,__PYX_ERR(0, 3505, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_RandomState); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3505, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = PyObject_IsInstance(__pyx_v_seed, __pyx_t_4); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 3505, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* … */ }
+3506: return seed
__Pyx_TraceLine(3506,0,__PYX_ERR(0, 3506, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_seed); __pyx_r = __pyx_v_seed; goto __pyx_L0;
+3507: raise ValueError(
__Pyx_TraceLine(3507,0,__PYX_ERR(0, 3507, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 3507, __pyx_L1_error)
+3508: "%r cannot be used to seed a numpy.random.RandomState instance" % seed
__Pyx_TraceLine(3508,0,__PYX_ERR(0, 3508, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_r_cannot_be_used_to_seed_a_nump, __pyx_v_seed); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
3509: )
3510:
+3511: def is_iterable (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_134is_iterable(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_133is_iterable, " Asserts iterable object and returns boolean or transform object into\n an iterable.\n \n Function can also transform a non-iterable object to an iterable if \n `transform` is set to ``True``.\n \n :param y: any, object to be asserted \n :param exclude_string: bool, does not consider string as an iterable \n object if `y` is passed as a string object. \n :param transform: bool, transform `y` to an iterable objects. But default \n puts `y` in a list object. \n :param parse_string: bool, parse string and convert the list of string \n into iterable object is the `y` is a string object and containg the \n word separator character '[#&.*@!_,;\\s-]'. Refer to the function \n :func:`~gofast.tools.coreutils.str2columns` documentation.\n \n :returns: \n - bool, or iterable object if `transform` is set to ``True``. \n \n .. note:: \n Parameter `parse_string` expects `transform` to be ``True``, otherwise \n a ValueError will raise. Note :func:`.is_iterable` is not dedicated \n for string parsing. It parses string using the default behaviour of \n :func:`.str2columns`. Use the latter for string parsing instead. \n \n :Examples: \n >>> from gofast.coreutils.is_iterable \n >>> is_iterable ('iterable', exclude_string= True ) \n Out[28]: False\n >>> is_iterable ('iterable', exclude_string= True , transform =True)\n Out[29]: ['iterable']\n >>> is_iterable ('iterable', transform =True)\n Out[30]: 'iterable'\n >>> is_iterable ('iterable', transform =True, parse_string=True)\n Out[31]: ['iterable']\n >>> is_iterable ('iterable', transform =True, exclude_string =True, \n parse_string=True)\n Out[32]: ['iterable']\n >>> is_iterable ('parse iterable object', parse_string=True, \n transform =True)\n Out[40]: ['parse', 'iterable', 'object']\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_134is_iterable = {"is_iterable", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_134is_iterable, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_133is_iterable}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_134is_iterable(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_y = 0; PyObject *__pyx_v_exclude_string = 0; PyObject *__pyx_v_transform = 0; PyObject *__pyx_v_parse_string = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_iterable (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_y_4,&__pyx_n_s_exclude_string,&__pyx_n_s_transform,&__pyx_n_s_parse_string,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_133is_iterable(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_y, PyObject *__pyx_v_exclude_string, PyObject *__pyx_v_transform, PyObject *__pyx_v_parse_string) { int __pyx_v_isiter; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__174) __Pyx_TraceCall("is_iterable", __pyx_f[0], 3511, 0, __PYX_ERR(0, 3511, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_y); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.is_iterable", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_y); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__441 = PyTuple_Pack(5, __pyx_n_s_y_4, __pyx_n_s_exclude_string, __pyx_n_s_transform, __pyx_n_s_parse_string, __pyx_n_s_isiter); if (unlikely(!__pyx_tuple__441)) __PYX_ERR(0, 3511, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__441); __Pyx_GIVEREF(__pyx_tuple__441); __pyx_codeobj__174 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__441, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_iterable, 3511, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__174)) __PYX_ERR(0, 3511, __pyx_L1_error) /* … */ __Pyx_TraceLine(3511,0,__PYX_ERR(0, 3511, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Union_bool_list) < 0) __PYX_ERR(0, 3511, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_134is_iterable, 0, __pyx_n_s_is_iterable, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__174)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3511, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__442); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_iterable, __pyx_t_4) < 0) __PYX_ERR(0, 3511, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_tuple__442 = PyTuple_Pack(3, ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__442)) __PYX_ERR(0, 3511, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__442); __Pyx_GIVEREF(__pyx_tuple__442);
+3512: y, exclude_string= False, transform = False , parse_string =False,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_y_4)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3511, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exclude_string); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3511, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_transform); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3511, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_parse_string); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3511, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "is_iterable") < 0)) __PYX_ERR(0, 3511, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_y = values[0]; __pyx_v_exclude_string = values[1]; __pyx_v_transform = values[2]; __pyx_v_parse_string = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_iterable", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 3511, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.is_iterable", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_133is_iterable(__pyx_self, __pyx_v_y, __pyx_v_exclude_string, __pyx_v_transform, __pyx_v_parse_string);
3513: )->Union [bool , list]:
3514: """ Asserts iterable object and returns boolean or transform object into
3515: an iterable.
3516:
3517: Function can also transform a non-iterable object to an iterable if
3518: `transform` is set to ``True``.
3519:
3520: :param y: any, object to be asserted
3521: :param exclude_string: bool, does not consider string as an iterable
3522: object if `y` is passed as a string object.
3523: :param transform: bool, transform `y` to an iterable objects. But default
3524: puts `y` in a list object.
3525: :param parse_string: bool, parse string and convert the list of string
3526: into iterable object is the `y` is a string object and containg the
3527: word separator character '[#&.*@!_,;\s-]'. Refer to the function
3528: :func:`~gofast.tools.coreutils.str2columns` documentation.
3529:
3530: :returns:
3531: - bool, or iterable object if `transform` is set to ``True``.
3532:
3533: .. note::
3534: Parameter `parse_string` expects `transform` to be ``True``, otherwise
3535: a ValueError will raise. Note :func:`.is_iterable` is not dedicated
3536: for string parsing. It parses string using the default behaviour of
3537: :func:`.str2columns`. Use the latter for string parsing instead.
3538:
3539: :Examples:
3540: >>> from gofast.coreutils.is_iterable
3541: >>> is_iterable ('iterable', exclude_string= True )
3542: Out[28]: False
3543: >>> is_iterable ('iterable', exclude_string= True , transform =True)
3544: Out[29]: ['iterable']
3545: >>> is_iterable ('iterable', transform =True)
3546: Out[30]: 'iterable'
3547: >>> is_iterable ('iterable', transform =True, parse_string=True)
3548: Out[31]: ['iterable']
3549: >>> is_iterable ('iterable', transform =True, exclude_string =True,
3550: parse_string=True)
3551: Out[32]: ['iterable']
3552: >>> is_iterable ('parse iterable object', parse_string=True,
3553: transform =True)
3554: Out[40]: ['parse', 'iterable', 'object']
3555: """
+3556: if (parse_string and not transform) and isinstance (y, str):
__Pyx_TraceLine(3556,0,__PYX_ERR(0, 3556, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_parse_string); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3556, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_transform); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3556, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = PyUnicode_Check(__pyx_v_y); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+3557: raise ValueError ("Cannot parse the given string. Set 'transform' to"
__Pyx_TraceLine(3557,0,__PYX_ERR(0, 3557, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__175, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 3557, __pyx_L1_error) /* … */ __pyx_tuple__175 = PyTuple_Pack(1, __pyx_kp_u_Cannot_parse_the_given_string_Se); if (unlikely(!__pyx_tuple__175)) __PYX_ERR(0, 3557, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__175); __Pyx_GIVEREF(__pyx_tuple__175);
3558: " ``True`` otherwise use the 'str2columns' utils"
3559: " from 'gofast.tools.coreutils' instead.")
+3560: y = str2columns(y) if isinstance(y, str) and parse_string else y
__Pyx_TraceLine(3560,0,__PYX_ERR(0, 3560, __pyx_L1_error)) __pyx_t_3 = PyUnicode_Check(__pyx_v_y); if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L7_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_parse_string); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 3560, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_L7_bool_binop_done:; if (__pyx_t_1) { __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_y}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } else { __Pyx_INCREF(__pyx_v_y); __pyx_t_4 = __pyx_v_y; } __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_4); __pyx_t_4 = 0;
3561:
+3562: isiter = False if exclude_string and isinstance (
__Pyx_TraceLine(3562,0,__PYX_ERR(0, 3562, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_exclude_string); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3562, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_3 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } /* … */ __Pyx_TraceLine(3562,0,__PYX_ERR(0, 3562, __pyx_L1_error)) __pyx_t_1 = 0; } else {
+3563: y, str) else hasattr (y, '__iter__')
__Pyx_TraceLine(3563,0,__PYX_ERR(0, 3563, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Check(__pyx_v_y); __pyx_t_3 = __pyx_t_2; __pyx_L9_bool_binop_done:; if (__pyx_t_3) { /* … */ __Pyx_TraceLine(3563,0,__PYX_ERR(0, 3563, __pyx_L1_error)) __pyx_t_2 = __Pyx_HasAttr(__pyx_v_y, __pyx_n_u_iter); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3563, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; } __pyx_v_isiter = __pyx_t_1;
3564:
+3565: return ( y if isiter else [ y ] ) if transform else isiter
__Pyx_TraceLine(3565,0,__PYX_ERR(0, 3565, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_transform); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3565, __pyx_L1_error) if (__pyx_t_1) { if (__pyx_v_isiter) { __Pyx_INCREF(__pyx_v_y); __pyx_t_5 = __pyx_v_y; } else { __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_y)) __PYX_ERR(0, 3565, __pyx_L1_error); __pyx_t_5 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } else { __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_isiter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
3566:
3567:
+3568: def str2columns (text, regex=None , pattern = None):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_136str2columns(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_135str2columns, "Split text from the non-alphanumeric markers using regular expression. \n \n Remove all string non-alphanumeric and some operator indicators, and \n fetch attributes names. \n \n Parameters \n -----------\n text: str, \n text litteral containing the columns the names to retrieve\n \n regex: `re` object, \n Regular expresion object. the default is:: \n \n >>> import re \n >>> re.compile (r'[#&*@!_,;\\s-]\\s*', flags=re.IGNORECASE) \n pattern: str, default = '[#&*@!_,;\\s-]\\s*'\n The base pattern to split the text into a columns\n \n Returns\n -------\n attr: List of attributes \n \n Examples\n ---------\n >>> from gofast.tools.coreutils import str2columns \n >>> text = ('this.is the text to split. It is an: example of; splitting str - to text.')\n >>> str2columns (text ) \n ... ['this',\n 'is',\n 'the',\n 'text',\n 'to',\n 'split',\n 'It',\n 'is',\n 'an:',\n 'example',\n 'of',\n 'splitting',\n 'str',\n 'to',\n 'text']\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_136str2columns = {"str2columns", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_136str2columns, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_135str2columns}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_136str2columns(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_text = 0; PyObject *__pyx_v_regex = 0; PyObject *__pyx_v_pattern = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("str2columns (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_text,&__pyx_n_s_regex,&__pyx_n_s_pattern,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_text)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3568, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3568, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3568, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "str2columns") < 0)) __PYX_ERR(0, 3568, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_text = values[0]; __pyx_v_regex = values[1]; __pyx_v_pattern = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("str2columns", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 3568, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.str2columns", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_135str2columns(__pyx_self, __pyx_v_text, __pyx_v_regex, __pyx_v_pattern); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_135str2columns(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_text, PyObject *__pyx_v_regex, PyObject *__pyx_v_pattern) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__176) __Pyx_TraceCall("str2columns", __pyx_f[0], 3568, 0, __PYX_ERR(0, 3568, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_text); __Pyx_INCREF(__pyx_v_regex); __Pyx_INCREF(__pyx_v_pattern); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.str2columns", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_text); __Pyx_XDECREF(__pyx_v_regex); __Pyx_XDECREF(__pyx_v_pattern); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__443 = PyTuple_Pack(3, __pyx_n_s_text, __pyx_n_s_regex, __pyx_n_s_pattern); if (unlikely(!__pyx_tuple__443)) __PYX_ERR(0, 3568, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__443); __Pyx_GIVEREF(__pyx_tuple__443); /* … */ __Pyx_TraceLine(3568,0,__PYX_ERR(0, 3568, __pyx_L1_error)) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_136str2columns, 0, __pyx_n_s_str2columns, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__176)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3568, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__226); if (PyDict_SetItem(__pyx_d, __pyx_n_s_str2columns, __pyx_t_4) < 0) __PYX_ERR(0, 3568, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__176 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__443, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_str2columns, 3568, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__176)) __PYX_ERR(0, 3568, __pyx_L1_error)
3569: """Split text from the non-alphanumeric markers using regular expression.
3570:
3571: Remove all string non-alphanumeric and some operator indicators, and
3572: fetch attributes names.
3573:
3574: Parameters
3575: -----------
3576: text: str,
3577: text litteral containing the columns the names to retrieve
3578:
3579: regex: `re` object,
3580: Regular expresion object. the default is::
3581:
3582: >>> import re
3583: >>> re.compile (r'[#&*@!_,;\s-]\s*', flags=re.IGNORECASE)
3584: pattern: str, default = '[#&*@!_,;\s-]\s*'
3585: The base pattern to split the text into a columns
3586:
3587: Returns
3588: -------
3589: attr: List of attributes
3590:
3591: Examples
3592: ---------
3593: >>> from gofast.tools.coreutils import str2columns
3594: >>> text = ('this.is the text to split. It is an: example of; splitting str - to text.')
3595: >>> str2columns (text )
3596: ... ['this',
3597: 'is',
3598: 'the',
3599: 'text',
3600: 'to',
3601: 'split',
3602: 'It',
3603: 'is',
3604: 'an:',
3605: 'example',
3606: 'of',
3607: 'splitting',
3608: 'str',
3609: 'to',
3610: 'text']
3611:
3612: """
+3613: pattern = pattern or r'[#&.*@!_,;\s-]\s*'
__Pyx_TraceLine(3613,0,__PYX_ERR(0, 3613, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_pattern); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3613, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_pattern); __pyx_t_1 = __pyx_v_pattern; goto __pyx_L3_bool_binop_done; } __Pyx_INCREF(__pyx_kp_u_s_s); __pyx_t_1 = __pyx_kp_u_s_s; __pyx_L3_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_pattern, __pyx_t_1); __pyx_t_1 = 0;
+3614: regex = regex or re.compile (pattern, flags=re.IGNORECASE)
__Pyx_TraceLine(3614,0,__PYX_ERR(0, 3614, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_regex); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3614, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_regex); __pyx_t_1 = __pyx_v_regex; goto __pyx_L5_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_compile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_pattern); __Pyx_GIVEREF(__pyx_v_pattern); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_pattern)) __PYX_ERR(0, 3614, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_re); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_flags, __pyx_t_7) < 0) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3614, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_t_7); __pyx_t_1 = __pyx_t_7; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_L5_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_regex, __pyx_t_1); __pyx_t_1 = 0;
+3615: text= list(filter (None, regex.split(str(text))))
__Pyx_TraceLine(3615,0,__PYX_ERR(0, 3615, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_regex, __pyx_n_s_split); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_Str(__pyx_v_text); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, Py_None)) __PYX_ERR(0, 3615, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1)) __PYX_ERR(0, 3615, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_filter, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_text, __pyx_t_7); __pyx_t_7 = 0;
+3616: return text
__Pyx_TraceLine(3616,0,__PYX_ERR(0, 3616, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_text); __pyx_r = __pyx_v_text; goto __pyx_L0;
3617:
+3618: def sanitize_frame_cols(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_138sanitize_frame_cols(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_137sanitize_frame_cols, " Remove an indesirable characters to the dataframe and returns \n new columns. \n \n Use regular expression for columns sanitizing \n \n Parameters \n -----------\n \n d: list, columns, \n columns to sanitize. It might contain a list of items to \n to polish. If dataframe or series are given, the dataframe columns \n and the name respectively will be polished and returns the same \n dataframe.\n \n func: _F, callable \n Universal function used to clean the columns \n \n regex: `re` object,\n Regular expresion object. the default is:: \n \n >>> import re \n >>> re.compile (r'[_#&.)(*@!_,;\\s-]\\s*', flags=re.IGNORECASE) \n pattern: str, default = '[_#&.)(*@!_,;\\s-]\\s*'\n The base pattern to sanitize the text in each column names. \n \n fill_pattern: str, default='' \n pattern to replace the non-alphabetic character in each item of \n columns. \n inplace: bool, default=False, \n transform the dataframe of series in place. \n\n Returns\n -------\n columns | pd.Series | dataframe. \n return Serie or dataframe if one is given, otherwise it returns a \n sanitized columns. \n \n Examples \n ---------\n >>> from gofast.tools.coreutils import sanitize_frame_cols \n >>> from gofast.tools.coreutils import read_data \n >>> h502= read_data ('data/boreholes/H502.xlsx') \n >>> h502 = sanitize_frame_cols (h502, fill_pattern ='_' ) \n >>> h502.columns[:3]\n ... Index(['depth_top', 'depth_bottom', 'strata_name'], dtype='object') \n >>> f = lambda r : r.replace ('_', \"'s \") \n >>> h502_f= sanitize_frame_cols( h502, func =f )\n >>> h502_f.columns [:3]\n ... Index(['depth's top', 'depth's bottom', 'strata's name'], dtype='object')\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_138sanitize_frame_cols = {"sanitize_frame_cols", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_138sanitize_frame_cols, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_137sanitize_frame_cols}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_138sanitize_frame_cols(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_func = 0; PyObject *__pyx_v_regex = 0; PyObject *__pyx_v_pattern = 0; PyObject *__pyx_v_fill_pattern = 0; PyObject *__pyx_v_inplace = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sanitize_frame_cols (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_func,&__pyx_n_s_regex,&__pyx_n_s_pattern,&__pyx_n_s_fill_pattern,&__pyx_n_s_inplace,0}; PyObject* values[6] = {0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_137sanitize_frame_cols(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_func, PyObject *__pyx_v_regex, PyObject *__pyx_v_pattern, PyObject *__pyx_v_fill_pattern, PyObject *__pyx_v_inplace) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols *__pyx_cur_scope; int __pyx_v_isf; int __pyx_v_iss; PyObject *__pyx_v_c = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__177) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 3618, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("sanitize_frame_cols", __pyx_f[0], 3618, 0, __PYX_ERR(0, 3618, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_regex = __pyx_v_regex; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_regex); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_regex); __pyx_cur_scope->__pyx_v_fill_pattern = __pyx_v_fill_pattern; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fill_pattern); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fill_pattern); __Pyx_INCREF(__pyx_v_d); __Pyx_INCREF(__pyx_v_pattern); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.sanitize_frame_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_c); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_pattern); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__444 = PyTuple_Pack(9, __pyx_n_s_d_3, __pyx_n_s_func, __pyx_n_s_regex, __pyx_n_s_pattern, __pyx_n_s_fill_pattern, __pyx_n_s_inplace, __pyx_n_s_isf, __pyx_n_s_iss, __pyx_n_s_c_2); if (unlikely(!__pyx_tuple__444)) __PYX_ERR(0, 3618, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__444); __Pyx_GIVEREF(__pyx_tuple__444); __pyx_codeobj__177 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__444, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_sanitize_frame_cols, 3618, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__177)) __PYX_ERR(0, 3618, __pyx_L1_error) /* … */ __Pyx_TraceLine(3618,0,__PYX_ERR(0, 3618, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_func, __pyx_n_s_F) < 0) __PYX_ERR(0, 3618, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3618, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_fill_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3618, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inplace, __pyx_n_s_bool) < 0) __PYX_ERR(0, 3618, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_138sanitize_frame_cols, 0, __pyx_n_s_sanitize_frame_cols, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__177)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__445); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_4); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_sanitize_frame_cols, __pyx_t_2) < 0) __PYX_ERR(0, 3618, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__445 = PyTuple_Pack(5, Py_None, Py_None, Py_None, Py_None, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__445)) __PYX_ERR(0, 3618, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__445); __Pyx_GIVEREF(__pyx_tuple__445); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols { PyObject_HEAD PyObject *__pyx_v_fill_pattern; PyObject *__pyx_v_regex; };
+3619: d, func:_F = None , regex=None, pattern:str = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+3620: fill_pattern:str =None, inplace:bool =False
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3618, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3618, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3618, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3618, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fill_pattern); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3618, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_inplace); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3618, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "sanitize_frame_cols") < 0)) __PYX_ERR(0, 3618, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_d = values[0]; __pyx_v_func = values[1]; __pyx_v_regex = values[2]; __pyx_v_pattern = ((PyObject*)values[3]); __pyx_v_fill_pattern = ((PyObject*)values[4]); __pyx_v_inplace = values[5]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sanitize_frame_cols", 0, 1, 6, __pyx_nargs); __PYX_ERR(0, 3618, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.sanitize_frame_cols", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern), (&PyUnicode_Type), 1, "pattern", 1))) __PYX_ERR(0, 3619, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fill_pattern), (&PyUnicode_Type), 1, "fill_pattern", 1))) __PYX_ERR(0, 3620, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_137sanitize_frame_cols(__pyx_self, __pyx_v_d, __pyx_v_func, __pyx_v_regex, __pyx_v_pattern, __pyx_v_fill_pattern, __pyx_v_inplace);
3621: ):
3622: """ Remove an indesirable characters to the dataframe and returns
3623: new columns.
3624:
3625: Use regular expression for columns sanitizing
3626:
3627: Parameters
3628: -----------
3629:
3630: d: list, columns,
3631: columns to sanitize. It might contain a list of items to
3632: to polish. If dataframe or series are given, the dataframe columns
3633: and the name respectively will be polished and returns the same
3634: dataframe.
3635:
3636: func: _F, callable
3637: Universal function used to clean the columns
3638:
3639: regex: `re` object,
3640: Regular expresion object. the default is::
3641:
3642: >>> import re
3643: >>> re.compile (r'[_#&.)(*@!_,;\s-]\s*', flags=re.IGNORECASE)
3644: pattern: str, default = '[_#&.)(*@!_,;\s-]\s*'
3645: The base pattern to sanitize the text in each column names.
3646:
3647: fill_pattern: str, default=''
3648: pattern to replace the non-alphabetic character in each item of
3649: columns.
3650: inplace: bool, default=False,
3651: transform the dataframe of series in place.
3652:
3653: Returns
3654: -------
3655: columns | pd.Series | dataframe.
3656: return Serie or dataframe if one is given, otherwise it returns a
3657: sanitized columns.
3658:
3659: Examples
3660: ---------
3661: >>> from gofast.tools.coreutils import sanitize_frame_cols
3662: >>> from gofast.tools.coreutils import read_data
3663: >>> h502= read_data ('data/boreholes/H502.xlsx')
3664: >>> h502 = sanitize_frame_cols (h502, fill_pattern ='_' )
3665: >>> h502.columns[:3]
3666: ... Index(['depth_top', 'depth_bottom', 'strata_name'], dtype='object')
3667: >>> f = lambda r : r.replace ('_', "'s ")
3668: >>> h502_f= sanitize_frame_cols( h502, func =f )
3669: >>> h502_f.columns [:3]
3670: ... Index(['depth's top', 'depth's bottom', 'strata's name'], dtype='object')
3671:
3672: """
+3673: isf , iss= False , False
__Pyx_TraceLine(3673,0,__PYX_ERR(0, 3673, __pyx_L1_error)) __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_v_isf = __pyx_t_1; __pyx_v_iss = __pyx_t_2;
+3674: pattern = pattern or r'[_#&.)(*@!_,;\s-]\s*'
__Pyx_TraceLine(3674,0,__PYX_ERR(0, 3674, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_pattern); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3674, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_pattern); __pyx_t_3 = __pyx_v_pattern; goto __pyx_L3_bool_binop_done; } __Pyx_INCREF(__pyx_kp_u_s_s_2); __pyx_t_3 = __pyx_kp_u_s_s_2; __pyx_L3_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_pattern, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
+3675: fill_pattern = fill_pattern or ''
__Pyx_TraceLine(3675,0,__PYX_ERR(0, 3675, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_fill_pattern); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3675, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fill_pattern); __pyx_t_3 = __pyx_cur_scope->__pyx_v_fill_pattern; goto __pyx_L5_bool_binop_done; } __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_3 = __pyx_kp_u__22; __pyx_L5_bool_binop_done:; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fill_pattern); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_fill_pattern, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
+3676: fill_pattern = str(fill_pattern)
__Pyx_TraceLine(3676,0,__PYX_ERR(0, 3676, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_cur_scope->__pyx_v_fill_pattern); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fill_pattern); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_fill_pattern, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
3677:
+3678: regex = regex or re.compile (pattern, flags=re.IGNORECASE)
__Pyx_TraceLine(3678,0,__PYX_ERR(0, 3678, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_regex); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3678, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_cur_scope->__pyx_v_regex); __pyx_t_3 = __pyx_cur_scope->__pyx_v_regex; goto __pyx_L7_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_compile); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_pattern); __Pyx_GIVEREF(__pyx_v_pattern); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_pattern)) __PYX_ERR(0, 3678, __pyx_L1_error); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_re); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_flags, __pyx_t_8) < 0) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_t_8); __pyx_t_3 = __pyx_t_8; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_L7_bool_binop_done:; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_regex); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_regex, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
3679:
+3680: if isinstance(d, pd.Series):
__Pyx_TraceLine(3680,0,__PYX_ERR(0, 3680, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Series); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3680, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = PyObject_IsInstance(__pyx_v_d, __pyx_t_8); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3680, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L9; }
+3681: c = [d.name]
__Pyx_TraceLine(3681,0,__PYX_ERR(0, 3681, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_name_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_8)) __PYX_ERR(0, 3681, __pyx_L1_error); __pyx_t_8 = 0; __pyx_v_c = __pyx_t_3; __pyx_t_3 = 0;
+3682: iss =True
__Pyx_TraceLine(3682,0,__PYX_ERR(0, 3682, __pyx_L1_error)) __pyx_v_iss = 1;
+3683: elif isinstance (d, pd.DataFrame ) :
__Pyx_TraceLine(3683,0,__PYX_ERR(0, 3683, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3683, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3683, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = PyObject_IsInstance(__pyx_v_d, __pyx_t_8); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3683, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L9; }
+3684: c = list(d.columns)
__Pyx_TraceLine(3684,0,__PYX_ERR(0, 3684, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_columns); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_c = __pyx_t_3; __pyx_t_3 = 0;
+3685: isf = True
__Pyx_TraceLine(3685,0,__PYX_ERR(0, 3685, __pyx_L1_error)) __pyx_v_isf = 1;
3686:
3687: else :
+3688: if not is_iterable(d) : c = [d]
__Pyx_TraceLine(3688,0,__PYX_ERR(0, 3688, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_d}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3688, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = (!__pyx_t_2); if (__pyx_t_1) { __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_d)) __PYX_ERR(0, 3688, __pyx_L1_error); __pyx_v_c = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L10; }
+3689: else : c = d
__Pyx_TraceLine(3689,0,__PYX_ERR(0, 3689, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_v_d); __pyx_v_c = __pyx_v_d; } __pyx_L10:; } __pyx_L9:;
3690:
+3691: if inspect.isfunction(func):
__Pyx_TraceLine(3691,0,__PYX_ERR(0, 3691, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_inspect); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_isfunction); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_v_func}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3691, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ goto __pyx_L11; }
+3692: c = list( map (func , c ) )
__Pyx_TraceLine(3692,0,__PYX_ERR(0, 3692, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_func); __Pyx_GIVEREF(__pyx_v_func); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_func)) __PYX_ERR(0, 3692, __pyx_L1_error); __Pyx_INCREF(__pyx_v_c); __Pyx_GIVEREF(__pyx_v_c); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_c)) __PYX_ERR(0, 3692, __pyx_L1_error); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3692, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_c, __pyx_t_3); __pyx_t_3 = 0;
3693:
+3694: else : c =list(map (
__Pyx_TraceLine(3694,0,__PYX_ERR(0, 3694, __pyx_L1_error)) /*else*/ { /* … */ __Pyx_TraceLine(3694,0,__PYX_ERR(0, 3694, __pyx_L1_error)) __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3)) __PYX_ERR(0, 3694, __pyx_L1_error); __Pyx_INCREF(__pyx_v_c); __Pyx_GIVEREF(__pyx_v_c); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_c)) __PYX_ERR(0, 3694, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_c, __pyx_t_6); __pyx_t_6 = 0; } __pyx_L11:;
+3695: lambda r : regex.sub(fill_pattern, r.strip() ), c ))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_19sanitize_frame_cols_lambda13(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_19sanitize_frame_cols_lambda13 = {"lambda13", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_19sanitize_frame_cols_lambda13, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_19sanitize_frame_cols_lambda13(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_r = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda13 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_r,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_r)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3695, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda13") < 0)) __PYX_ERR(0, 3695, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_r = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda13", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 3695, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.sanitize_frame_cols.lambda13", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda13(__pyx_self, __pyx_v_r);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda13(PyObject *__pyx_self, PyObject *__pyx_v_r) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_12_sanitize_frame_cols *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda13", __pyx_f[0], 3695, 0, __PYX_ERR(0, 3695, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_regex)) { __Pyx_RaiseClosureNameError("regex"); __PYX_ERR(0, 3695, __pyx_L1_error) }
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_regex, __pyx_n_s_sub); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3695, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (unlikely(!__pyx_cur_scope->__pyx_v_fill_pattern)) { __Pyx_RaiseClosureNameError("fill_pattern"); __PYX_ERR(0, 3695, __pyx_L1_error) }
__pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_r, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3695, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = NULL;
__pyx_t_6 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_4))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_4, function);
__pyx_t_6 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
__pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3695, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
}
__pyx_t_4 = NULL;
__pyx_t_6 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_6 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_fill_pattern, __pyx_t_3};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3695, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("gofast.tools.coreutils.sanitize_frame_cols.lambda13", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(3695,0,__PYX_ERR(0, 3695, __pyx_L1_error))
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_19sanitize_frame_cols_lambda13, 0, __pyx_n_s_sanitize_frame_cols_locals_lambd, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3695, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
3696:
+3697: if isf :
__Pyx_TraceLine(3697,0,__PYX_ERR(0, 3697, __pyx_L1_error)) if (__pyx_v_isf) { /* … */ goto __pyx_L12; }
+3698: if inplace : d.columns = c
__Pyx_TraceLine(3698,0,__PYX_ERR(0, 3698, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_inplace); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3698, __pyx_L1_error) if (__pyx_t_1) { if (__Pyx_PyObject_SetAttrStr(__pyx_v_d, __pyx_n_s_columns, __pyx_v_c) < 0) __PYX_ERR(0, 3698, __pyx_L1_error) goto __pyx_L13; }
+3699: else : d =pd.DataFrame(d.values, columns =c )
__Pyx_TraceLine(3699,0,__PYX_ERR(0, 3699, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_values); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6)) __PYX_ERR(0, 3699, __pyx_L1_error); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_columns, __pyx_v_c) < 0) __PYX_ERR(0, 3699, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_4); __pyx_t_4 = 0; } __pyx_L13:;
3700:
+3701: elif iss:
__Pyx_TraceLine(3701,0,__PYX_ERR(0, 3701, __pyx_L1_error)) if (__pyx_v_iss) { /* … */ goto __pyx_L12; }
+3702: if inplace: d.name = c[0]
__Pyx_TraceLine(3702,0,__PYX_ERR(0, 3702, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_inplace); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3702, __pyx_L1_error) if (__pyx_t_1) { __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_c, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (__Pyx_PyObject_SetAttrStr(__pyx_v_d, __pyx_n_s_name_2, __pyx_t_4) < 0) __PYX_ERR(0, 3702, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L14; }
+3703: else : d= pd.Series (data =d.values, name =c[0] )
__Pyx_TraceLine(3703,0,__PYX_ERR(0, 3703, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_Series); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_values); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_data, __pyx_t_8) < 0) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_c, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_name_2, __pyx_t_8) < 0) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_8); __pyx_t_8 = 0; } __pyx_L14:;
3704:
+3705: else : d = c
__Pyx_TraceLine(3705,0,__PYX_ERR(0, 3705, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_v_c); __Pyx_DECREF_SET(__pyx_v_d, __pyx_v_c); } __pyx_L12:;
3706:
+3707: return d
__Pyx_TraceLine(3707,0,__PYX_ERR(0, 3707, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_d); __pyx_r = __pyx_v_d; goto __pyx_L0;
3708:
+3709: def to_hdf5(d, fn, objname =None, close =True, **hdf5_kws):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_140to_hdf5(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_139to_hdf5, "\n Store a frame data in hierachical data format 5 (HDF5) \n \n Note that is `d` is a dataframe, make sure that the dependency 'pytables'\n is already installed, otherwise and error raises. \n \n Parameters \n -----------\n d: ndarray, \n data to store in HDF5 format \n fn: str, \n File path to HDF5 file.\n objname: str, \n name of the data to store \n close: bool, default =True \n when data is given as an array, data can still be added if \n close is set to ``False``, otherwise, users need to open again in \n read mode 'r' before pursuing the process of adding. \n hdf5_kws: dict of :class:`pandas.pd.HDFStore` \n Additional keywords arguments passed to pd.HDFStore. they could be:\n * mode : {'a', 'w', 'r', 'r+'}, default 'a'\n \n ``'r'``\n Read-only; no data can be modified.\n ``'w'``\n Write; a new file is created (an existing file with the same\n name would be deleted).\n ``'a'``\n Append; an existing file is opened for reading and writing,\n and if the file does not exist it is created.\n ``'r+'``\n It is similar to ``'a'``, but the file must already exist.\n * complevel : int, 0-9, default None\n Specifies a compression level for data.\n A value of 0 or None disables compression.\n * complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib'\n Specifies the compression library to be used.\n As of v0.20.2 these additional compressors for Blosc are supported\n (default if no compressor specified: 'blosc:blosclz'):\n {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy',\n 'blosc:zlib', 'blosc:zstd'}.\n Specifying a compression library which is not available issues\n a ValueError.\n * fletc""her32 : bool, default False\n If applying compression use the fletcher32 checksum.\n Returns\n ------- \n store : Dict-like IO interface for storing pandas objects.\n \n Examples \n ------------\n >>> import os \n >>> from gofast.tools.coreutils import sanitize_frame_cols, to_hdf5 \n >>> from gofast.tools import read_data \n >>> data = read_data('data/boreholes/H502.xlsx') \n >>> sanitize_frame_cols (data, fill_pattern='_', inplace =True ) \n >>> store_path = os.path.join('gofast/datasets/data', 'h') # 'h' is the name of the data \n >>> store = to_hdf5 (data, fn =store_path , objname ='h502' ) \n >>> store \n ... \n >>> # fetch the data \n >>> h502 = store ['h502'] \n >>> h502.columns[:3] \n ... Index(['hole_number', 'depth_top', 'depth_bottom'], dtype='object')\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_140to_hdf5 = {"to_hdf5", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_140to_hdf5, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_139to_hdf5}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_140to_hdf5(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_fn = 0; PyObject *__pyx_v_objname = 0; PyObject *__pyx_v_close = 0; PyObject *__pyx_v_hdf5_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_hdf5 (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_hdf5_kws = PyDict_New(); if (unlikely(!__pyx_v_hdf5_kws)) return NULL; __Pyx_GOTREF(__pyx_v_hdf5_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_fn,&__pyx_n_s_objname,&__pyx_n_s_close,0}; PyObject* values[4] = {0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3709, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fn)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3709, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("to_hdf5", 0, 2, 4, 1); __PYX_ERR(0, 3709, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_objname); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3709, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_close); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3709, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_hdf5_kws, values + 0, kwd_pos_args, "to_hdf5") < 0)) __PYX_ERR(0, 3709, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_d = values[0]; __pyx_v_fn = values[1]; __pyx_v_objname = values[2]; __pyx_v_close = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_hdf5", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 3709, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_hdf5_kws); __pyx_v_hdf5_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.to_hdf5", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_139to_hdf5(__pyx_self, __pyx_v_d, __pyx_v_fn, __pyx_v_objname, __pyx_v_close, __pyx_v_hdf5_kws); /* function exit code */ __Pyx_DECREF(__pyx_v_hdf5_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_139to_hdf5(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_fn, PyObject *__pyx_v_objname, PyObject *__pyx_v_close, PyObject *__pyx_v_hdf5_kws) { PyObject *__pyx_v_store = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__178) __Pyx_TraceCall("to_hdf5", __pyx_f[0], 3709, 0, __PYX_ERR(0, 3709, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_d); __Pyx_INCREF(__pyx_v_fn); __Pyx_INCREF(__pyx_v_objname); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.to_hdf5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_store); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_fn); __Pyx_XDECREF(__pyx_v_objname); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__446 = PyTuple_Pack(6, __pyx_n_s_d_3, __pyx_n_s_fn, __pyx_n_s_objname, __pyx_n_s_close, __pyx_n_s_hdf5_kws, __pyx_n_s_store); if (unlikely(!__pyx_tuple__446)) __PYX_ERR(0, 3709, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__446); __Pyx_GIVEREF(__pyx_tuple__446); __pyx_codeobj__178 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__446, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_to_hdf5, 3709, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__178)) __PYX_ERR(0, 3709, __pyx_L1_error) /* … */ __Pyx_TraceLine(3709,0,__PYX_ERR(0, 3709, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_140to_hdf5, 0, __pyx_n_s_to_hdf5, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__178)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__447); if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_hdf5, __pyx_t_2) < 0) __PYX_ERR(0, 3709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__447 = PyTuple_Pack(2, Py_None, ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__447)) __PYX_ERR(0, 3709, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__447); __Pyx_GIVEREF(__pyx_tuple__447);
3710: """
3711: Store a frame data in hierachical data format 5 (HDF5)
3712:
3713: Note that is `d` is a dataframe, make sure that the dependency 'pytables'
3714: is already installed, otherwise and error raises.
3715:
3716: Parameters
3717: -----------
3718: d: ndarray,
3719: data to store in HDF5 format
3720: fn: str,
3721: File path to HDF5 file.
3722: objname: str,
3723: name of the data to store
3724: close: bool, default =True
3725: when data is given as an array, data can still be added if
3726: close is set to ``False``, otherwise, users need to open again in
3727: read mode 'r' before pursuing the process of adding.
3728: hdf5_kws: dict of :class:`pandas.pd.HDFStore`
3729: Additional keywords arguments passed to pd.HDFStore. they could be:
3730: * mode : {'a', 'w', 'r', 'r+'}, default 'a'
3731:
3732: ``'r'``
3733: Read-only; no data can be modified.
3734: ``'w'``
3735: Write; a new file is created (an existing file with the same
3736: name would be deleted).
3737: ``'a'``
3738: Append; an existing file is opened for reading and writing,
3739: and if the file does not exist it is created.
3740: ``'r+'``
3741: It is similar to ``'a'``, but the file must already exist.
3742: * complevel : int, 0-9, default None
3743: Specifies a compression level for data.
3744: A value of 0 or None disables compression.
3745: * complib : {'zlib', 'lzo', 'bzip2', 'blosc'}, default 'zlib'
3746: Specifies the compression library to be used.
3747: As of v0.20.2 these additional compressors for Blosc are supported
3748: (default if no compressor specified: 'blosc:blosclz'):
3749: {'blosc:blosclz', 'blosc:lz4', 'blosc:lz4hc', 'blosc:snappy',
3750: 'blosc:zlib', 'blosc:zstd'}.
3751: Specifying a compression library which is not available issues
3752: a ValueError.
3753: * fletcher32 : bool, default False
3754: If applying compression use the fletcher32 checksum.
3755: Returns
3756: -------
3757: store : Dict-like IO interface for storing pandas objects.
3758:
3759: Examples
3760: ------------
3761: >>> import os
3762: >>> from gofast.tools.coreutils import sanitize_frame_cols, to_hdf5
3763: >>> from gofast.tools import read_data
3764: >>> data = read_data('data/boreholes/H502.xlsx')
3765: >>> sanitize_frame_cols (data, fill_pattern='_', inplace =True )
3766: >>> store_path = os.path.join('gofast/datasets/data', 'h') # 'h' is the name of the data
3767: >>> store = to_hdf5 (data, fn =store_path , objname ='h502' )
3768: >>> store
3769: ...
3770: >>> # fetch the data
3771: >>> h502 = store ['h502']
3772: >>> h502.columns[:3]
3773: ... Index(['hole_number', 'depth_top', 'depth_bottom'], dtype='object')
3774:
3775: """
+3776: store =None
__Pyx_TraceLine(3776,0,__PYX_ERR(0, 3776, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_store = Py_None;
+3777: if (
__Pyx_TraceLine(3777,0,__PYX_ERR(0, 3777, __pyx_L1_error)) if (unlikely(__pyx_t_1)) { /* … */ }
+3778: not hasattr (d, '__array__')
__Pyx_TraceLine(3778,0,__PYX_ERR(0, 3778, __pyx_L1_error)) __pyx_t_2 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_array_2); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3778, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_2); if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; }
+3779: or not hasattr (d, 'columns')
__Pyx_TraceLine(3779,0,__PYX_ERR(0, 3779, __pyx_L1_error)) __pyx_t_3 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_columns); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 3779, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_3); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:;
3780: ) :
+3781: raise TypeError ("Expect an array or dataframe,"
__Pyx_TraceLine(3781,0,__PYX_ERR(0, 3781, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_an_array_or_dataframe_not, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 3781, __pyx_L1_error)
+3782: f" not {type (d).__name__!r}")
__Pyx_TraceLine(3782,0,__PYX_ERR(0, 3782, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_d)), __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_4), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3783:
+3784: if hasattr (d, '__array__') and hasattr (d, "columns"):
__Pyx_TraceLine(3784,0,__PYX_ERR(0, 3784, __pyx_L1_error)) __pyx_t_2 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_array_2); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3784, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L7_bool_binop_done; } __pyx_t_2 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_columns); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3784, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_L7_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L6; }
3785: # assert whether pytables is installed
+3786: import_optional_dependency ('tables')
__Pyx_TraceLine(3786,0,__PYX_ERR(0, 3786, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_import_optional_dependency); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_n_u_tables}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3786, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3787: # remove extension if exist.
+3788: fn = str(fn).replace ('.h5', "").replace(".hdf5", "")
__Pyx_TraceLine(3788,0,__PYX_ERR(0, 3788, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Str(__pyx_v_fn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_replace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__179, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_replace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_tuple__179 = PyTuple_Pack(2, __pyx_kp_u_h5, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__179)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__179); __Pyx_GIVEREF(__pyx_tuple__179); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__180, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_fn, __pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__180 = PyTuple_Pack(2, __pyx_kp_u_hdf5, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__180)) __PYX_ERR(0, 3788, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__180); __Pyx_GIVEREF(__pyx_tuple__180);
3789: # then store.
+3790: store = pd.HDFStore(fn +'.h5' , **hdf5_kws)
__Pyx_TraceLine(3790,0,__PYX_ERR(0, 3790, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_HDFStore); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyNumber_Add(__pyx_v_fn, __pyx_kp_u_h5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5)) __PYX_ERR(0, 3790, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = PyDict_Copy(__pyx_v_hdf5_kws); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3790, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_store, __pyx_t_8); __pyx_t_8 = 0;
+3791: objname = objname or 'data'
__Pyx_TraceLine(3791,0,__PYX_ERR(0, 3791, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_objname); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3791, __pyx_L1_error) if (!__pyx_t_1) { } else { __Pyx_INCREF(__pyx_v_objname); __pyx_t_8 = __pyx_v_objname; goto __pyx_L9_bool_binop_done; } __Pyx_INCREF(__pyx_n_u_data); __pyx_t_8 = __pyx_n_u_data; __pyx_L9_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_objname, __pyx_t_8); __pyx_t_8 = 0;
+3792: store[ str(objname) ] = d
__Pyx_TraceLine(3792,0,__PYX_ERR(0, 3792, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Str(__pyx_v_objname); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3792, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (unlikely((PyObject_SetItem(__pyx_v_store, __pyx_t_8, __pyx_v_d) < 0))) __PYX_ERR(0, 3792, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3793:
3794:
+3795: elif not hasattr(d, '__array__'):
__Pyx_TraceLine(3795,0,__PYX_ERR(0, 3795, __pyx_L1_error)) __pyx_t_1 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_array_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 3795, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ } __pyx_L6:;
+3796: d = np.asarray(d)
__Pyx_TraceLine(3796,0,__PYX_ERR(0, 3796, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_asarray); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_d}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_8); __pyx_t_8 = 0;
3797:
+3798: store= h5py.File(f"{fn}.hdf5", "w")
__Pyx_TraceLine(3798,0,__PYX_ERR(0, 3798, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_h5py); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_File_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v_fn, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_6, __pyx_kp_u_hdf5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_4, __pyx_n_u_w}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_store, __pyx_t_8); __pyx_t_8 = 0;
+3799: store.create_dataset("dataset_01", store.shape,
__Pyx_TraceLine(3799,0,__PYX_ERR(0, 3799, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_store, __pyx_n_s_create_dataset); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_store, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_u_dataset_01); __Pyx_GIVEREF(__pyx_n_u_dataset_01); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_n_u_dataset_01)) __PYX_ERR(0, 3799, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5)) __PYX_ERR(0, 3799, __pyx_L1_error); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(3799,0,__PYX_ERR(0, 3799, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3799, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+3800: dtype=store.dtype,
__Pyx_TraceLine(3800,0,__PYX_ERR(0, 3800, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_store, __pyx_n_s_dtype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3800, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_6) < 0) __PYX_ERR(0, 3800, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+3801: data=store
__Pyx_TraceLine(3801,0,__PYX_ERR(0, 3801, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_v_store) < 0) __PYX_ERR(0, 3800, __pyx_L1_error)
3802: )
3803:
+3804: if close : store.close ()
__Pyx_TraceLine(3804,0,__PYX_ERR(0, 3804, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_close); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3804, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_store, __pyx_n_s_close); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; }
3805:
+3806: return store
__Pyx_TraceLine(3806,0,__PYX_ERR(0, 3806, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_store); __pyx_r = __pyx_v_store; goto __pyx_L0;
3807:
3808:
+3809: def find_by_regex (o , pattern, func = re.match, **kws ):
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_324__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 3809, 0, __PYX_ERR(0, 3809, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_func);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_func);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self)->__pyx_arg_func)) __PYX_ERR(0, 3809, __pyx_L1_error);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 3809, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 3809, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_142find_by_regex(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_141find_by_regex, " Find pattern in object whatever an \"iterable\" or not. \n \n when we talk about iterable, a string value is not included.\n \n Parameters \n -------------\n o: str or iterable, \n text litteral or an iterable object containing or not the specific \n object to match. \n pattern: str, default = '[_#&*@!_,;\\s-]\\s*'\n The base pattern to split the text into a columns\n \n func: re callable , default=re.match\n regular expression search function. Can be\n [re.match, re.findall, re.search ],or any other regular expression \n function. \n \n * ``re.match()``: function searches the regular expression pattern and \n return the first occurrence. The Python RegEx Match method checks \n for a match only at the beginning of the string. So, if a match is \n found in the first line, it returns the match object. But if a match \n is found in some other line, the Python RegEx Match function returns \n null.\n * ``re.search()``: function will search the regular expression pattern \n and return the first occurrence. Unlike Python re.match(), it will \n check all lines of the input string. The Python re.search() function \n returns a match object when the pattern is found and \342\200\234null\342\200\235 if \n the pattern is not found\n * ``re.findall()`` module is used to search for 'all' occurrences that \n match a given pattern. In contrast, search() module will only \n return the first occurrence that matches the specified pattern. \n findall() will iterate over all the lines of the file and will \n return all non-overlapping matches of pattern in a single step.\n kws: dict, \n Additional keywords arguments passed to functions :func:`re.match` or \n :func:`re.search` or :func:`re.findall`. \n \n Returns \n ---""----\n om: list \n matched object put is the list \n \n Example\n --------\n >>> from gofast.tools.coreutils import find_by_regex\n >>> from gofast.datasets import load_hlogs \n >>> X0, _= load_hlogs (as_frame =True )\n >>> columns = X0.columns \n >>> str_columns =','.join (columns) \n >>> find_by_regex (str_columns , pattern='depth', func=re.search)\n ... ['depth']\n >>> find_by_regex(columns, pattern ='depth', func=re.search)\n ... ['depth_top', 'depth_bottom']\n \n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_142find_by_regex = {"find_by_regex", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_142find_by_regex, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_141find_by_regex};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_142find_by_regex(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_o = 0;
PyObject *__pyx_v_pattern = 0;
PyObject *__pyx_v_func = 0;
PyObject *__pyx_v_kws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("find_by_regex (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL;
__Pyx_GOTREF(__pyx_v_kws);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,&__pyx_n_s_pattern,&__pyx_n_s_func,0};
PyObject* values[3] = {0,0,0};
__pyx_defaults9 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_self);
values[2] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_func);
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3809, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3809, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("find_by_regex", 0, 2, 3, 1); __PYX_ERR(0, 3809, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3809, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "find_by_regex") < 0)) __PYX_ERR(0, 3809, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_o = values[0];
__pyx_v_pattern = values[1];
__pyx_v_func = values[2];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("find_by_regex", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 3809, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0;
__Pyx_AddTraceback("gofast.tools.coreutils.find_by_regex", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_141find_by_regex(__pyx_self, __pyx_v_o, __pyx_v_pattern, __pyx_v_func, __pyx_v_kws);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
__Pyx_DECREF(__pyx_v_kws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_141find_by_regex(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_o, PyObject *__pyx_v_pattern, PyObject *__pyx_v_func, PyObject *__pyx_v_kws) {
PyObject *__pyx_v_om = NULL;
PyObject *__pyx_v_s = NULL;
PyObject *__pyx_v_z = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__181)
__Pyx_TraceCall("find_by_regex", __pyx_f[0], 3809, 0, __PYX_ERR(0, 3809, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_o);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.find_by_regex", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_om);
__Pyx_XDECREF(__pyx_v_s);
__Pyx_XDECREF(__pyx_v_z);
__Pyx_XDECREF(__pyx_v_o);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__448 = PyTuple_Pack(7, __pyx_n_s_o, __pyx_n_s_pattern, __pyx_n_s_func, __pyx_n_s_kws_2, __pyx_n_s_om, __pyx_n_s_s_2, __pyx_n_s_z); if (unlikely(!__pyx_tuple__448)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__448);
__Pyx_GIVEREF(__pyx_tuple__448);
/* … */
__Pyx_TraceLine(3809,0,__PYX_ERR(0, 3809, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_142find_by_regex, 0, __pyx_n_s_find_by_regex, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__181)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults9), 1)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_match); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_CyFunction_Defaults(__pyx_defaults9, __pyx_t_2)->__pyx_arg_func = __pyx_t_5;
__Pyx_GIVEREF(__pyx_t_5);
__pyx_t_5 = 0;
__Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_6gofast_5tools_9coreutils_324__defaults__);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_find_by_regex, __pyx_t_2) < 0) __PYX_ERR(0, 3809, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_codeobj__181 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__448, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_find_by_regex, 3809, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__181)) __PYX_ERR(0, 3809, __pyx_L1_error)
3810: """ Find pattern in object whatever an "iterable" or not.
3811:
3812: when we talk about iterable, a string value is not included.
3813:
3814: Parameters
3815: -------------
3816: o: str or iterable,
3817: text litteral or an iterable object containing or not the specific
3818: object to match.
3819: pattern: str, default = '[_#&*@!_,;\s-]\s*'
3820: The base pattern to split the text into a columns
3821:
3822: func: re callable , default=re.match
3823: regular expression search function. Can be
3824: [re.match, re.findall, re.search ],or any other regular expression
3825: function.
3826:
3827: * ``re.match()``: function searches the regular expression pattern and
3828: return the first occurrence. The Python RegEx Match method checks
3829: for a match only at the beginning of the string. So, if a match is
3830: found in the first line, it returns the match object. But if a match
3831: is found in some other line, the Python RegEx Match function returns
3832: null.
3833: * ``re.search()``: function will search the regular expression pattern
3834: and return the first occurrence. Unlike Python re.match(), it will
3835: check all lines of the input string. The Python re.search() function
3836: returns a match object when the pattern is found and “null” if
3837: the pattern is not found
3838: * ``re.findall()`` module is used to search for 'all' occurrences that
3839: match a given pattern. In contrast, search() module will only
3840: return the first occurrence that matches the specified pattern.
3841: findall() will iterate over all the lines of the file and will
3842: return all non-overlapping matches of pattern in a single step.
3843: kws: dict,
3844: Additional keywords arguments passed to functions :func:`re.match` or
3845: :func:`re.search` or :func:`re.findall`.
3846:
3847: Returns
3848: -------
3849: om: list
3850: matched object put is the list
3851:
3852: Example
3853: --------
3854: >>> from gofast.tools.coreutils import find_by_regex
3855: >>> from gofast.datasets import load_hlogs
3856: >>> X0, _= load_hlogs (as_frame =True )
3857: >>> columns = X0.columns
3858: >>> str_columns =','.join (columns)
3859: >>> find_by_regex (str_columns , pattern='depth', func=re.search)
3860: ... ['depth']
3861: >>> find_by_regex(columns, pattern ='depth', func=re.search)
3862: ... ['depth_top', 'depth_bottom']
3863:
3864: """
+3865: om = []
__Pyx_TraceLine(3865,0,__PYX_ERR(0, 3865, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3865, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_om = __pyx_t_1; __pyx_t_1 = 0;
+3866: if isinstance (o, str):
__Pyx_TraceLine(3866,0,__PYX_ERR(0, 3866, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Check(__pyx_v_o); if (__pyx_t_2) { /* … */ goto __pyx_L3; }
+3867: om = func ( pattern=pattern , string = o, **kws)
__Pyx_TraceLine(3867,0,__PYX_ERR(0, 3867, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 3867, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_string, __pyx_v_o) < 0) __PYX_ERR(0, 3867, __pyx_L1_error) __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; if (__Pyx_MergeKeywords(__pyx_t_1, __pyx_v_kws) < 0) __PYX_ERR(0, 3867, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_func, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3867, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_om, __pyx_t_3); __pyx_t_3 = 0;
+3868: if om:
__Pyx_TraceLine(3868,0,__PYX_ERR(0, 3868, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_om); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3868, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+3869: om= om.group()
__Pyx_TraceLine(3869,0,__PYX_ERR(0, 3869, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_om, __pyx_n_s_group); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3869, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_om, __pyx_t_3); __pyx_t_3 = 0;
+3870: om =[om]
__Pyx_TraceLine(3870,0,__PYX_ERR(0, 3870, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_om); __Pyx_GIVEREF(__pyx_v_om); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_om)) __PYX_ERR(0, 3870, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_om, __pyx_t_3); __pyx_t_3 = 0;
+3871: elif is_iterable(o):
__Pyx_TraceLine(3871,0,__PYX_ERR(0, 3871, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3871, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_o}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3871, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3871, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ } __pyx_L3:;
+3872: o = list(o)
__Pyx_TraceLine(3872,0,__PYX_ERR(0, 3872, __pyx_L1_error)) __pyx_t_3 = PySequence_List(__pyx_v_o); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_o, __pyx_t_3); __pyx_t_3 = 0;
+3873: for s in o :
__Pyx_TraceLine(3873,0,__PYX_ERR(0, 3873, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_o)) || PyTuple_CheckExact(__pyx_v_o)) { __pyx_t_3 = __pyx_v_o; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_o); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3873, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3873, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3873, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 3873, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3873, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3873, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 3873, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3873, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 3873, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(3873,0,__PYX_ERR(0, 3873, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+3874: z = func (pattern =pattern , string = s, **kws)
__Pyx_TraceLine(3874,0,__PYX_ERR(0, 3874, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3874, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 3874, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_string, __pyx_v_s) < 0) __PYX_ERR(0, 3874, __pyx_L1_error) __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; if (__Pyx_MergeKeywords(__pyx_t_1, __pyx_v_kws) < 0) __PYX_ERR(0, 3874, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_func, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3874, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF_SET(__pyx_v_z, __pyx_t_4); __pyx_t_4 = 0;
+3875: if z :
__Pyx_TraceLine(3875,0,__PYX_ERR(0, 3875, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_z); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3875, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+3876: om.append (s)
__Pyx_TraceLine(3876,0,__PYX_ERR(0, 3876, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Append(__pyx_v_om, __pyx_v_s); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 3876, __pyx_L1_error)
3877:
+3878: if func.__name__=='findall':
__Pyx_TraceLine(3878,0,__PYX_ERR(0, 3878, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_func, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3878, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_findall, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3878, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { /* … */ }
+3879: om = list(itertools.chain (*om ))
__Pyx_TraceLine(3879,0,__PYX_ERR(0, 3879, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_itertools); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_chain); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_v_om); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3879, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_om, __pyx_t_3); __pyx_t_3 = 0;
3880: # keep None is nothing
3881: # fit the corresponding pattern
+3882: if len(om) ==0 or om[0] is None:
__Pyx_TraceLine(3882,0,__PYX_ERR(0, 3882, __pyx_L1_error)) __pyx_t_6 = PyObject_Length(__pyx_v_om); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3882, __pyx_L1_error) __pyx_t_9 = (__pyx_t_6 == 0); if (!__pyx_t_9) { } else { __pyx_t_2 = __pyx_t_9; goto __pyx_L11_bool_binop_done; } __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_om, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = (__pyx_t_3 == Py_None); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_9; __pyx_L11_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+3883: om = None
__Pyx_TraceLine(3883,0,__PYX_ERR(0, 3883, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_om, Py_None);
+3884: return om
__Pyx_TraceLine(3884,0,__PYX_ERR(0, 3884, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_om); __pyx_r = __pyx_v_om; goto __pyx_L0;
3885:
+3886: def is_in_if (o: iter, items: Union [str , iter], error = 'raise',
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_144is_in_if(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_143is_in_if, " Raise error if item is not found in the iterable object 'o' \n \n :param o: unhashable type, iterable object, \n object for checkin. It assumes to be an iterable from which 'items' \n is premused to be in. \n :param items: str or list, \n Items to assert whether it is in `o` or not. \n :param error: str, default='raise'\n raise or ignore error when none item is found in `o`. \n :param return_diff: bool, \n returns the difference items which is/are not included in 'items' \n if `return_diff` is ``True``, will put error to ``ignore`` \n systematically.\n :param return_intersect:bool,default=False\n returns items as the intersection between `o` and `items`.\n :raise: ValueError \n raise ValueError if `items` not in `o`. \n :return: list, \n `s` : object found in ``o` or the difference object i.e the object \n that is not in `items` provided that `error` is set to ``ignore``.\n Note that if None object is found and `error` is ``ignore`` , it \n will return ``None``, otherwise, a `ValueError` raises. \n \n :example: \n >>> from gofast.datasets import load_hlogs \n >>> from gofast.tools.coreutils import is_in_if \n >>> X0, _= load_hlogs (as_frame =True )\n >>> is_in_if (X0 , items= ['depth_top', 'top']) \n ... ValueError: Item 'top' is missing in the object \n >>> is_in_if (X0, ['depth_top', 'top'] , error ='ignore') \n ... ['depth_top']\n >>> is_in_if (X0, ['depth_top', 'top'] , error ='ignore',\n return_diff= True) \n ... ['sp',\n 'well_diameter',\n 'layer_thickness',\n 'natural_gamma',\n 'short_distance_gamma',\n 'strata_name',\n 'gamma_gamma',\n 'depth_bottom',\n 'rock_name',\n 'resistivity',\n 'hole_id']\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_144is_in_if = {"is_in_if", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_144is_in_if, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_143is_in_if}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_144is_in_if(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_o = 0; PyObject *__pyx_v_items = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_return_diff = 0; PyObject *__pyx_v_return_intersect = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_in_if (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,&__pyx_n_s_items,&__pyx_n_s_error,&__pyx_n_s_return_diff,&__pyx_n_s_return_intersect,0}; PyObject* values[5] = {0,0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_raise))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_143is_in_if(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_o, PyObject *__pyx_v_items, PyObject *__pyx_v_error, PyObject *__pyx_v_return_diff, PyObject *__pyx_v_return_intersect) { PyObject *__pyx_v_s = NULL; PyObject *__pyx_v_miss_items = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_verb = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__182) __Pyx_TraceCall("is_in_if", __pyx_f[0], 3886, 0, __PYX_ERR(0, 3886, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_items); __Pyx_INCREF(__pyx_v_error); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.is_in_if", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s); __Pyx_XDECREF(__pyx_v_miss_items); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_verb); __Pyx_XDECREF(__pyx_v_items); __Pyx_XDECREF(__pyx_v_error); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__449 = PyTuple_Pack(9, __pyx_n_s_o, __pyx_n_s_items, __pyx_n_s_error, __pyx_n_s_return_diff, __pyx_n_s_return_intersect, __pyx_n_s_s_2, __pyx_n_s_miss_items, __pyx_n_s_v, __pyx_n_s_verb); if (unlikely(!__pyx_tuple__449)) __PYX_ERR(0, 3886, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__449); __Pyx_GIVEREF(__pyx_tuple__449); __pyx_codeobj__182 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__449, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_in_if, 3886, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__182)) __PYX_ERR(0, 3886, __pyx_L1_error) /* … */ __Pyx_TraceLine(3886,0,__PYX_ERR(0, 3886, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3886, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_o, __pyx_n_s_iter_2) < 0) __PYX_ERR(0, 3886, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_items, __pyx_kp_s_Union_str_iter) < 0) __PYX_ERR(0, 3886, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_144is_in_if, 0, __pyx_n_s_is_in_if, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__182)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3886, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__450); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_in_if, __pyx_t_5) < 0) __PYX_ERR(0, 3886, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__450 = PyTuple_Pack(3, ((PyObject*)__pyx_n_u_raise), ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__450)) __PYX_ERR(0, 3886, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__450); __Pyx_GIVEREF(__pyx_tuple__450);
+3887: return_diff =False, return_intersect = False):
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3886, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_items)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3886, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("is_in_if", 0, 2, 5, 1); __PYX_ERR(0, 3886, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_error); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3886, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_diff); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3886, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_intersect); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3886, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "is_in_if") < 0)) __PYX_ERR(0, 3886, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_o = values[0]; __pyx_v_items = values[1]; __pyx_v_error = values[2]; __pyx_v_return_diff = values[3]; __pyx_v_return_intersect = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_in_if", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 3886, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.is_in_if", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_143is_in_if(__pyx_self, __pyx_v_o, __pyx_v_items, __pyx_v_error, __pyx_v_return_diff, __pyx_v_return_intersect);
3888: """ Raise error if item is not found in the iterable object 'o'
3889:
3890: :param o: unhashable type, iterable object,
3891: object for checkin. It assumes to be an iterable from which 'items'
3892: is premused to be in.
3893: :param items: str or list,
3894: Items to assert whether it is in `o` or not.
3895: :param error: str, default='raise'
3896: raise or ignore error when none item is found in `o`.
3897: :param return_diff: bool,
3898: returns the difference items which is/are not included in 'items'
3899: if `return_diff` is ``True``, will put error to ``ignore``
3900: systematically.
3901: :param return_intersect:bool,default=False
3902: returns items as the intersection between `o` and `items`.
3903: :raise: ValueError
3904: raise ValueError if `items` not in `o`.
3905: :return: list,
3906: `s` : object found in ``o` or the difference object i.e the object
3907: that is not in `items` provided that `error` is set to ``ignore``.
3908: Note that if None object is found and `error` is ``ignore`` , it
3909: will return ``None``, otherwise, a `ValueError` raises.
3910:
3911: :example:
3912: >>> from gofast.datasets import load_hlogs
3913: >>> from gofast.tools.coreutils import is_in_if
3914: >>> X0, _= load_hlogs (as_frame =True )
3915: >>> is_in_if (X0 , items= ['depth_top', 'top'])
3916: ... ValueError: Item 'top' is missing in the object
3917: >>> is_in_if (X0, ['depth_top', 'top'] , error ='ignore')
3918: ... ['depth_top']
3919: >>> is_in_if (X0, ['depth_top', 'top'] , error ='ignore',
3920: return_diff= True)
3921: ... ['sp',
3922: 'well_diameter',
3923: 'layer_thickness',
3924: 'natural_gamma',
3925: 'short_distance_gamma',
3926: 'strata_name',
3927: 'gamma_gamma',
3928: 'depth_bottom',
3929: 'rock_name',
3930: 'resistivity',
3931: 'hole_id']
3932: """
3933:
+3934: if isinstance (items, str):
__Pyx_TraceLine(3934,0,__PYX_ERR(0, 3934, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_items); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+3935: items =[items]
__Pyx_TraceLine(3935,0,__PYX_ERR(0, 3935, __pyx_L1_error)) __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_items); __Pyx_GIVEREF(__pyx_v_items); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_v_items)) __PYX_ERR(0, 3935, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_items, __pyx_t_2); __pyx_t_2 = 0;
+3936: elif not is_iterable(o):
__Pyx_TraceLine(3936,0,__PYX_ERR(0, 3936, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3936, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_o}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3936, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3936, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (!__pyx_t_1); if (unlikely(__pyx_t_6)) { /* … */ } __pyx_L3:;
+3937: raise TypeError (f"Expect an iterable object, not {type(o).__name__!r}")
__Pyx_TraceLine(3937,0,__PYX_ERR(0, 3937, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_o)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_an_iterable_object_not, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 3937, __pyx_L1_error)
3938: # find intersect object
+3939: s= set (o).intersection (items)
__Pyx_TraceLine(3939,0,__PYX_ERR(0, 3939, __pyx_L1_error)) __pyx_t_2 = PySet_New(__pyx_v_o); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_intersection); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_items}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_s = __pyx_t_3; __pyx_t_3 = 0;
3940:
+3941: miss_items = list(s.difference (o)) if len(s) > len(
__Pyx_TraceLine(3941,0,__PYX_ERR(0, 3941, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3941, __pyx_L1_error) /* … */ __Pyx_TraceLine(3942,0,__PYX_ERR(0, 3942, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3941, __pyx_L1_error) /* … */ __Pyx_TraceLine(3941,0,__PYX_ERR(0, 3941, __pyx_L1_error)) __pyx_t_6 = (__pyx_t_7 > __pyx_t_8); if (__pyx_t_6) { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_difference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_o}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3941, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else {
+3942: items) else list(set(items).difference (s))
__Pyx_TraceLine(3942,0,__PYX_ERR(0, 3942, __pyx_L1_error)) __pyx_t_4 = PySet_New(__pyx_v_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_difference); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_s}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3942, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_v_miss_items = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
3943:
+3944: if return_diff or return_intersect:
__Pyx_TraceLine(3944,0,__PYX_ERR(0, 3944, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_return_diff); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3944, __pyx_L1_error) if (!__pyx_t_1) { } else { __pyx_t_6 = __pyx_t_1; goto __pyx_L5_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_return_intersect); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3944, __pyx_L1_error) __pyx_t_6 = __pyx_t_1; __pyx_L5_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+3945: error ='ignore'
__Pyx_TraceLine(3945,0,__PYX_ERR(0, 3945, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_ignore); __Pyx_DECREF_SET(__pyx_v_error, __pyx_n_u_ignore);
3946:
+3947: if len(miss_items)!=0 :
__Pyx_TraceLine(3947,0,__PYX_ERR(0, 3947, __pyx_L1_error)) if (unlikely(__pyx_v_miss_items == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 3947, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyList_GET_SIZE(__pyx_v_miss_items); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3947, __pyx_L1_error) __pyx_t_6 = (__pyx_t_8 != 0); if (__pyx_t_6) { /* … */ }
+3948: if error =='raise':
__Pyx_TraceLine(3948,0,__PYX_ERR(0, 3948, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3948, __pyx_L1_error) if (unlikely(__pyx_t_6)) { /* … */ }
+3949: v= smart_format(miss_items)
__Pyx_TraceLine(3949,0,__PYX_ERR(0, 3949, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3949, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_miss_items}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3949, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_v_v = __pyx_t_3; __pyx_t_3 = 0;
+3950: verb = f"{ ' '+ v +' is' if len(miss_items)<2 else 's '+ v + 'are'}"
__Pyx_TraceLine(3950,0,__PYX_ERR(0, 3950, __pyx_L1_error)) if (unlikely(__pyx_v_miss_items == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 3950, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyList_GET_SIZE(__pyx_v_miss_items); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3950, __pyx_L1_error) __pyx_t_6 = (__pyx_t_8 < 2); if (__pyx_t_6) { __pyx_t_9 = PyNumber_Add(__pyx_kp_u__14, __pyx_v_v); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = PyNumber_Add(__pyx_t_9, __pyx_kp_u_is); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else { __pyx_t_2 = PyNumber_Add(__pyx_kp_u_s_4, __pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_n_u_are); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_verb = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0;
+3951: raise ValueError (
__Pyx_TraceLine(3951,0,__PYX_ERR(0, 3951, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 3951, __pyx_L1_error)
+3952: f"Item{verb} missing in the {type(o).__name__.lower()} {o}.")
__Pyx_TraceLine(3952,0,__PYX_ERR(0, 3952, __pyx_L1_error)) __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_8 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_n_u_Item); __pyx_t_8 += 4; __Pyx_GIVEREF(__pyx_n_u_Item); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_n_u_Item); __Pyx_INCREF(__pyx_v_verb); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_verb) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_verb) : __pyx_t_10; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_verb); __Pyx_GIVEREF(__pyx_v_verb); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_verb); __Pyx_INCREF(__pyx_kp_u_missing_in_the); __pyx_t_8 += 16; __Pyx_GIVEREF(__pyx_kp_u_missing_in_the); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u_missing_in_the); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_o)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_10; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_kp_u__14); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_o, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_10; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_kp_u__26); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_9, 7, __pyx_t_8, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3953:
3954:
+3955: if return_diff :
__Pyx_TraceLine(3955,0,__PYX_ERR(0, 3955, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_return_diff); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3955, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L9; }
3956: # get difference
+3957: s = list(set(o).difference (s)) if len(o) > len(
__Pyx_TraceLine(3957,0,__PYX_ERR(0, 3957, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3957, __pyx_L1_error) /* … */ __Pyx_TraceLine(3958,0,__PYX_ERR(0, 3958, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3957, __pyx_L1_error) /* … */ __Pyx_TraceLine(3957,0,__PYX_ERR(0, 3957, __pyx_L1_error)) __pyx_t_6 = (__pyx_t_8 > __pyx_t_7); if (__pyx_t_6) { __pyx_t_3 = PySet_New(__pyx_v_o); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3957, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_difference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3957, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_s}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3957, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3957, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = __pyx_t_2; __pyx_t_2 = 0; } else {
+3958: s) else list(set(items).difference (s))
__Pyx_TraceLine(3958,0,__PYX_ERR(0, 3958, __pyx_L1_error)) __pyx_t_4 = PySet_New(__pyx_v_items); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_difference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_s}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __pyx_t_3; __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_9); __pyx_t_9 = 0;
3959: # s = set(o).difference (s)
+3960: elif return_intersect:
__Pyx_TraceLine(3960,0,__PYX_ERR(0, 3960, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_return_intersect); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3960, __pyx_L1_error) if (__pyx_t_6) { /* … */ } __pyx_L9:;
+3961: s = list(set(o).intersection(s)) if len(o) > len(
__Pyx_TraceLine(3961,0,__PYX_ERR(0, 3961, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3961, __pyx_L1_error) /* … */ __Pyx_TraceLine(3962,0,__PYX_ERR(0, 3962, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3961, __pyx_L1_error) /* … */ __Pyx_TraceLine(3961,0,__PYX_ERR(0, 3961, __pyx_L1_error)) __pyx_t_6 = (__pyx_t_7 > __pyx_t_8); if (__pyx_t_6) { __pyx_t_2 = PySet_New(__pyx_v_o); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_intersection); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_s}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = __pyx_t_4; __pyx_t_4 = 0; } else {
+3962: items) else list(set(items).intersection (s))
__Pyx_TraceLine(3962,0,__PYX_ERR(0, 3962, __pyx_L1_error)) __pyx_t_3 = PySet_New(__pyx_v_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_intersection); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_s}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3962, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_9); __pyx_t_9 = 0;
3963:
+3964: s = None if len(s)==0 else list (s)
__Pyx_TraceLine(3964,0,__PYX_ERR(0, 3964, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3964, __pyx_L1_error) __pyx_t_6 = (__pyx_t_8 == 0); if (__pyx_t_6) { __Pyx_INCREF(Py_None); __pyx_t_9 = Py_None; } else { __pyx_t_2 = PySequence_List(__pyx_v_s); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_9); __pyx_t_9 = 0;
3965:
+3966: return s
__Pyx_TraceLine(3966,0,__PYX_ERR(0, 3966, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_s); __pyx_r = __pyx_v_s; goto __pyx_L0;
3967:
+3968: def map_specific_columns (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_146map_specific_columns(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_145map_specific_columns, " Apply function to a specific columns is the dataframe. \n \n It is possible to skip some columns that we want operation to not be \n performed.\n \n Parameters \n -----------\n X: dataframe, \n pandas dataframe with valid columns \n ufunc: callable, \n Universal function that can be applying to the dataframe. \n columns_to_skip: list or str , \n List of columns to skip. If given as string and separed by the default\n pattern items, it should be converted to a list and make sure the \n columns name exist in the dataframe. Otherwise an error with \n raise.\n \n pattern: str, default = '[#&*@!,;\\s]\\s*'\n The base pattern to split the text in `column2skip` into a columns\n For instance, the following string coulb be splitted to:: \n \n 'depth_top, thickness, sp, gamma_gamma' -> \n ['depth_top', 'thickness', 'sp', 'gamma_gamma']\n \n Refer to :func:`~.str2columns` for further details. \n inplace: bool, default=True \n Modified dataframe in place and return None, otherwise return a \n new dataframe \n kws: dict, \n Keywords argument passed to :func: `pandas.DataFrame.apply` function \n \n Returns \n ---------\n X: Dataframe or None \n Dataframe modified inplace with values computed using the given \n `func`except the skipped columns, or ``None`` if `inplace` is ``True``. \n \n Examples \n ---------\n >>> from gofast.datasets import load_hlogs \n >>> from gofast.tools.plotutils import map_specific_columns \n >>> X0, _= load_hlogs (as_frame =True ) \n >>> # let visualize the first3 values of `sp` and `resistivity` keys \n >>> X0['sp'][:3] , X0['resistivity'][:3] \n ... (0 -1.580000\n 1 -1.580000\n 2 -1.922632\n Name: sp, dtype: float64,\n 0 15.919130\n 1 16.000000\n 2 24.422316\n "" Name: resistivity, dtype: float64)\n >>> column2skip = ['hole_id','depth_top', 'depth_bottom', \n 'strata_name', 'rock_name', 'well_diameter', 'sp']\n >>> map_specific_columns (X0, ufunc = np.log10, column2skip)\n >>> # now let visualize the same keys values \n >>> X0['sp'][:3] , X0['resistivity'][:3]\n ... (0 -1.580000\n 1 -1.580000\n 2 -1.922632\n Name: sp, dtype: float64,\n 0 1.201919\n 1 1.204120\n 2 1.387787\n Name: resistivity, dtype: float64)\n >>> # it is obvious the `resistiviy` values is log10 \n >>> # while `sp` stil remains the same \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_146map_specific_columns = {"map_specific_columns", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_146map_specific_columns, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_145map_specific_columns}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_146map_specific_columns(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_X = 0; PyObject *__pyx_v_ufunc = 0; PyObject *__pyx_v_columns_to_skip = 0; PyObject *__pyx_v_pattern = 0; PyObject *__pyx_v_inplace = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("map_specific_columns (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,&__pyx_n_s_ufunc,&__pyx_n_s_columns_to_skip,&__pyx_n_s_pattern,&__pyx_n_s_inplace,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_145map_specific_columns(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_X, PyObject *__pyx_v_ufunc, PyObject *__pyx_v_columns_to_skip, PyObject *__pyx_v_pattern, PyObject *__pyx_v_inplace, PyObject *__pyx_v_kws) { PyObject *__pyx_v_cskip = NULL; PyObject *__pyx_v_X0 = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__183) __Pyx_TraceCall("map_specific_columns", __pyx_f[0], 3968, 0, __PYX_ERR(0, 3968, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_X); __Pyx_INCREF(__pyx_v_columns_to_skip); __Pyx_INCREF(__pyx_v_pattern); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.map_specific_columns", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cskip); __Pyx_XDECREF(__pyx_v_X0); __Pyx_XDECREF(__pyx_v_X); __Pyx_XDECREF(__pyx_v_columns_to_skip); __Pyx_XDECREF(__pyx_v_pattern); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__451 = PyTuple_Pack(8, __pyx_n_s_X, __pyx_n_s_ufunc, __pyx_n_s_columns_to_skip, __pyx_n_s_pattern, __pyx_n_s_inplace, __pyx_n_s_kws_2, __pyx_n_s_cskip, __pyx_n_s_X0); if (unlikely(!__pyx_tuple__451)) __PYX_ERR(0, 3968, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__451); __Pyx_GIVEREF(__pyx_tuple__451); __pyx_codeobj__183 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__451, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_map_specific_columns, 3968, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__183)) __PYX_ERR(0, 3968, __pyx_L1_error) /* … */ __Pyx_TraceLine(3968,0,__PYX_ERR(0, 3968, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_X, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 3968, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_ufunc, __pyx_n_s_F) < 0) __PYX_ERR(0, 3968, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_columns_to_skip, __pyx_kp_s_List_str) < 0) __PYX_ERR(0, 3968, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 3968, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_inplace, __pyx_n_s_bool) < 0) __PYX_ERR(0, 3968, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_146map_specific_columns, 0, __pyx_n_s_map_specific_columns, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__183)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3968, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__452); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_map_specific_columns, __pyx_t_2) < 0) __PYX_ERR(0, 3968, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__452 = PyTuple_Pack(3, Py_None, Py_None, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__452)) __PYX_ERR(0, 3968, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__452); __Pyx_GIVEREF(__pyx_tuple__452);
3969: X: DataFrame,
3970: ufunc:_F ,
+3971: columns_to_skip:List[str]=None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+3972: pattern:str=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+3973: inplace:bool= False,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_X)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3968, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ufunc)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3968, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("map_specific_columns", 0, 2, 5, 1); __PYX_ERR(0, 3968, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns_to_skip); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3968, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3968, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_inplace); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 3968, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "map_specific_columns") < 0)) __PYX_ERR(0, 3968, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_X = values[0]; __pyx_v_ufunc = values[1]; __pyx_v_columns_to_skip = values[2]; __pyx_v_pattern = ((PyObject*)values[3]); __pyx_v_inplace = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("map_specific_columns", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 3968, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.map_specific_columns", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern), (&PyUnicode_Type), 1, "pattern", 1))) __PYX_ERR(0, 3972, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_145map_specific_columns(__pyx_self, __pyx_v_X, __pyx_v_ufunc, __pyx_v_columns_to_skip, __pyx_v_pattern, __pyx_v_inplace, __pyx_v_kws);
3974: **kws
3975: ):
3976: """ Apply function to a specific columns is the dataframe.
3977:
3978: It is possible to skip some columns that we want operation to not be
3979: performed.
3980:
3981: Parameters
3982: -----------
3983: X: dataframe,
3984: pandas dataframe with valid columns
3985: ufunc: callable,
3986: Universal function that can be applying to the dataframe.
3987: columns_to_skip: list or str ,
3988: List of columns to skip. If given as string and separed by the default
3989: pattern items, it should be converted to a list and make sure the
3990: columns name exist in the dataframe. Otherwise an error with
3991: raise.
3992:
3993: pattern: str, default = '[#&*@!,;\s]\s*'
3994: The base pattern to split the text in `column2skip` into a columns
3995: For instance, the following string coulb be splitted to::
3996:
3997: 'depth_top, thickness, sp, gamma_gamma' ->
3998: ['depth_top', 'thickness', 'sp', 'gamma_gamma']
3999:
4000: Refer to :func:`~.str2columns` for further details.
4001: inplace: bool, default=True
4002: Modified dataframe in place and return None, otherwise return a
4003: new dataframe
4004: kws: dict,
4005: Keywords argument passed to :func: `pandas.DataFrame.apply` function
4006:
4007: Returns
4008: ---------
4009: X: Dataframe or None
4010: Dataframe modified inplace with values computed using the given
4011: `func`except the skipped columns, or ``None`` if `inplace` is ``True``.
4012:
4013: Examples
4014: ---------
4015: >>> from gofast.datasets import load_hlogs
4016: >>> from gofast.tools.plotutils import map_specific_columns
4017: >>> X0, _= load_hlogs (as_frame =True )
4018: >>> # let visualize the first3 values of `sp` and `resistivity` keys
4019: >>> X0['sp'][:3] , X0['resistivity'][:3]
4020: ... (0 -1.580000
4021: 1 -1.580000
4022: 2 -1.922632
4023: Name: sp, dtype: float64,
4024: 0 15.919130
4025: 1 16.000000
4026: 2 24.422316
4027: Name: resistivity, dtype: float64)
4028: >>> column2skip = ['hole_id','depth_top', 'depth_bottom',
4029: 'strata_name', 'rock_name', 'well_diameter', 'sp']
4030: >>> map_specific_columns (X0, ufunc = np.log10, column2skip)
4031: >>> # now let visualize the same keys values
4032: >>> X0['sp'][:3] , X0['resistivity'][:3]
4033: ... (0 -1.580000
4034: 1 -1.580000
4035: 2 -1.922632
4036: Name: sp, dtype: float64,
4037: 0 1.201919
4038: 1 1.204120
4039: 2 1.387787
4040: Name: resistivity, dtype: float64)
4041: >>> # it is obvious the `resistiviy` values is log10
4042: >>> # while `sp` stil remains the same
4043:
4044: """
+4045: X = _assert_all_types(X, pd.DataFrame)
__Pyx_TraceLine(4045,0,__PYX_ERR(0, 4045, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_X, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4045, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_X, __pyx_t_1); __pyx_t_1 = 0;
+4046: if not callable(ufunc):
__Pyx_TraceLine(4046,0,__PYX_ERR(0, 4046, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyCallable_Check(__pyx_v_ufunc); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 4046, __pyx_L1_error) __pyx_t_7 = (!__pyx_t_6); if (unlikely(__pyx_t_7)) { /* … */ }
+4047: raise TypeError ("Expect a function for `ufunc`; "
__Pyx_TraceLine(4047,0,__PYX_ERR(0, 4047, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_a_function_for_ufunc_got, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 4047, __pyx_L1_error)
+4048: f"got {type(ufunc).__name__!r}")
__Pyx_TraceLine(4048,0,__PYX_ERR(0, 4048, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_ufunc)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4048, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_1), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4048, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4049:
+4050: pattern = pattern or r'[#&*@!,;\s]\s*'
__Pyx_TraceLine(4050,0,__PYX_ERR(0, 4050, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_pattern); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4050, __pyx_L1_error) if (!__pyx_t_7) { } else { __Pyx_INCREF(__pyx_v_pattern); __pyx_t_2 = __pyx_v_pattern; goto __pyx_L4_bool_binop_done; } __Pyx_INCREF(__pyx_kp_u_s_s_3); __pyx_t_2 = __pyx_kp_u_s_s_3; __pyx_L4_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_pattern, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
+4051: if not is_iterable( columns_to_skip):
__Pyx_TraceLine(4051,0,__PYX_ERR(0, 4051, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_columns_to_skip}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4051, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (!__pyx_t_7); if (unlikely(__pyx_t_6)) { /* … */ }
+4052: raise TypeError ("Columns to skip expect an iterable object;"
__Pyx_TraceLine(4052,0,__PYX_ERR(0, 4052, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Columns_to_skip_expect_an_iterab, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4052, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4052, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4052, __pyx_L1_error)
+4053: f" got {type(columns_to_skip).__name__!r}")
__Pyx_TraceLine(4053,0,__PYX_ERR(0, 4053, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_columns_to_skip)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4054:
+4055: if isinstance(columns_to_skip, str):
__Pyx_TraceLine(4055,0,__PYX_ERR(0, 4055, __pyx_L1_error)) __pyx_t_6 = PyUnicode_Check(__pyx_v_columns_to_skip); if (__pyx_t_6) { /* … */ }
+4056: columns_to_skip = str2columns (columns_to_skip, pattern=pattern )
__Pyx_TraceLine(4056,0,__PYX_ERR(0, 4056, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4056, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4056, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_columns_to_skip); __Pyx_GIVEREF(__pyx_v_columns_to_skip); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_columns_to_skip)) __PYX_ERR(0, 4056, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4056, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 4056, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4056, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_columns_to_skip, __pyx_t_3); __pyx_t_3 = 0;
4057: #assert whether column to skip is in
+4058: if columns_to_skip:
__Pyx_TraceLine(4058,0,__PYX_ERR(0, 4058, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_columns_to_skip); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4058, __pyx_L1_error) if (__pyx_t_6) { /* … */ goto __pyx_L8; }
+4059: cskip = copy.deepcopy(columns_to_skip)
__Pyx_TraceLine(4059,0,__PYX_ERR(0, 4059, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4059, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4059, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_columns_to_skip}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4059, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_cskip = __pyx_t_3; __pyx_t_3 = 0;
+4060: columns_to_skip = is_in_if(X.columns, columns_to_skip, return_diff= True)
__Pyx_TraceLine(4060,0,__PYX_ERR(0, 4060, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_in_if); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2)) __PYX_ERR(0, 4060, __pyx_L1_error); __Pyx_INCREF(__pyx_v_columns_to_skip); __Pyx_GIVEREF(__pyx_v_columns_to_skip); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_columns_to_skip)) __PYX_ERR(0, 4060, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return_diff, Py_True) < 0) __PYX_ERR(0, 4060, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4060, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_columns_to_skip, __pyx_t_1); __pyx_t_1 = 0;
+4061: if len(columns_to_skip) ==len (X.columns):
__Pyx_TraceLine(4061,0,__PYX_ERR(0, 4061, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_columns_to_skip); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4061, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4061, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4061, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (__pyx_t_8 == __pyx_t_9); if (__pyx_t_6) { /* … */ }
+4062: warnings.warn("Value(s) to skip are not detected.")
__Pyx_TraceLine(4062,0,__PYX_ERR(0, 4062, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_u_Value_s_to_skip_are_not_detected}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+4063: elif columns_to_skip is None:
__Pyx_TraceLine(4063,0,__PYX_ERR(0, 4063, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_columns_to_skip == Py_None); if (__pyx_t_6) { /* … */ } __pyx_L8:;
+4064: columns_to_skip = list(X.columns)
__Pyx_TraceLine(4064,0,__PYX_ERR(0, 4064, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_columns_to_skip, __pyx_t_4); __pyx_t_4 = 0;
4065:
+4066: if inplace :
__Pyx_TraceLine(4066,0,__PYX_ERR(0, 4066, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_inplace); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4066, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+4067: X[columns_to_skip] = X[columns_to_skip].apply (
__Pyx_TraceLine(4067,0,__PYX_ERR(0, 4067, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_X, __pyx_v_columns_to_skip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_apply); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(4068,0,__PYX_ERR(0, 4068, __pyx_L1_error)) __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_ufunc); __Pyx_GIVEREF(__pyx_v_ufunc); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_ufunc)) __PYX_ERR(0, 4067, __pyx_L1_error); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4067, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely((PyObject_SetItem(__pyx_v_X, __pyx_v_columns_to_skip, __pyx_t_3) < 0))) __PYX_ERR(0, 4067, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+4068: ufunc , **kws)
__Pyx_TraceLine(4067,0,__PYX_ERR(0, 4067, __pyx_L1_error)) __pyx_t_2 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+4069: X.drop (columns = cskip , inplace =True )
__Pyx_TraceLine(4069,0,__PYX_ERR(0, 4069, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_drop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(!__pyx_v_cskip)) { __Pyx_RaiseUnboundLocalError("cskip"); __PYX_ERR(0, 4069, __pyx_L1_error) } if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_v_cskip) < 0) __PYX_ERR(0, 4069, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 4069, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4069, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+4070: return
__Pyx_TraceLine(4070,0,__PYX_ERR(0, 4070, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+4071: if not inplace:
__Pyx_TraceLine(4071,0,__PYX_ERR(0, 4071, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_inplace); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4071, __pyx_L1_error) __pyx_t_7 = (!__pyx_t_6); if (__pyx_t_7) { /* … */ }
+4072: X0 = X.copy()
__Pyx_TraceLine(4072,0,__PYX_ERR(0, 4072, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4072, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_X0 = __pyx_t_4; __pyx_t_4 = 0;
+4073: X0[columns_to_skip] = X0[columns_to_skip].apply (
__Pyx_TraceLine(4073,0,__PYX_ERR(0, 4073, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_X0, __pyx_v_columns_to_skip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_apply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(4074,0,__PYX_ERR(0, 4074, __pyx_L1_error)) __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_ufunc); __Pyx_GIVEREF(__pyx_v_ufunc); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_ufunc)) __PYX_ERR(0, 4073, __pyx_L1_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely((PyObject_SetItem(__pyx_v_X0, __pyx_v_columns_to_skip, __pyx_t_1) < 0))) __PYX_ERR(0, 4073, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+4074: ufunc , **kws)
__Pyx_TraceLine(4073,0,__PYX_ERR(0, 4073, __pyx_L1_error)) __pyx_t_3 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3);
4075:
+4076: return X0
__Pyx_TraceLine(4076,0,__PYX_ERR(0, 4076, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_X0); __pyx_r = __pyx_v_X0; goto __pyx_L0;
4077:
+4078: def is_depth_in (X, name, columns = None, error= 'ignore'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_148is_depth_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_147is_depth_in, " Assert wether depth exists in the data from column attributes. \n \n If name is an integer value, it assumes to be the index in the columns \n of the dataframe if not exist , a warming will be show to user. \n \n :param X: dataframe \n dataframe containing the data for plotting \n \n :param columns: list,\n New labels to replace the columns in the dataframe. If given , it \n should fit the number of colums of `X`. \n \n :param name: str, int \n depth name in the dataframe or index to retreive the name of the depth \n in dataframe \n :param error: str , default='ignore'\n Raise or ignore when depth is not found in the dataframe. Whe error is \n set to ``ignore``, a pseudo-depth is created using the lenght of the \n the dataframe, otherwise a valueError raises.\n \n :return: X, depth \n Dataframe without the depth columns and depth values.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_148is_depth_in = {"is_depth_in", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_148is_depth_in, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_147is_depth_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_148is_depth_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_X = 0; PyObject *__pyx_v_name = 0; PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_error = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_depth_in (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,&__pyx_n_s_name_2,&__pyx_n_s_columns,&__pyx_n_s_error,0}; PyObject* values[4] = {0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_ignore))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_X)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4078, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4078, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("is_depth_in", 0, 2, 4, 1); __PYX_ERR(0, 4078, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4078, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_error); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4078, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "is_depth_in") < 0)) __PYX_ERR(0, 4078, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_X = values[0]; __pyx_v_name = values[1]; __pyx_v_columns = values[2]; __pyx_v_error = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_depth_in", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 4078, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.is_depth_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_147is_depth_in(__pyx_self, __pyx_v_X, __pyx_v_name, __pyx_v_columns, __pyx_v_error); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_147is_depth_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_X, PyObject *__pyx_v_name, PyObject *__pyx_v_columns, PyObject *__pyx_v_error) { PyObject *__pyx_v_n = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_v_depth = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__184) __Pyx_TraceCall("is_depth_in", __pyx_f[0], 4078, 0, __PYX_ERR(0, 4078, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_X); __Pyx_INCREF(__pyx_v_name); __Pyx_INCREF(__pyx_v_columns); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.is_depth_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_depth); __Pyx_XDECREF(__pyx_v_X); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_columns); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__453 = PyTuple_Pack(7, __pyx_n_s_X, __pyx_n_s_name_2, __pyx_n_s_columns, __pyx_n_s_error, __pyx_n_s_n, __pyx_n_s_msg, __pyx_n_s_depth); if (unlikely(!__pyx_tuple__453)) __PYX_ERR(0, 4078, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__453); __Pyx_GIVEREF(__pyx_tuple__453); __pyx_codeobj__184 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__453, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_depth_in, 4078, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__184)) __PYX_ERR(0, 4078, __pyx_L1_error) /* … */ __Pyx_TraceLine(4078,0,__PYX_ERR(0, 4078, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_148is_depth_in, 0, __pyx_n_s_is_depth_in, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__184)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4078, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__454); if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_depth_in, __pyx_t_2) < 0) __PYX_ERR(0, 4078, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__454 = PyTuple_Pack(2, Py_None, ((PyObject*)__pyx_n_u_ignore)); if (unlikely(!__pyx_tuple__454)) __PYX_ERR(0, 4078, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__454); __Pyx_GIVEREF(__pyx_tuple__454);
4079: """ Assert wether depth exists in the data from column attributes.
4080:
4081: If name is an integer value, it assumes to be the index in the columns
4082: of the dataframe if not exist , a warming will be show to user.
4083:
4084: :param X: dataframe
4085: dataframe containing the data for plotting
4086:
4087: :param columns: list,
4088: New labels to replace the columns in the dataframe. If given , it
4089: should fit the number of colums of `X`.
4090:
4091: :param name: str, int
4092: depth name in the dataframe or index to retreive the name of the depth
4093: in dataframe
4094: :param error: str , default='ignore'
4095: Raise or ignore when depth is not found in the dataframe. Whe error is
4096: set to ``ignore``, a pseudo-depth is created using the lenght of the
4097: the dataframe, otherwise a valueError raises.
4098:
4099: :return: X, depth
4100: Dataframe without the depth columns and depth values.
4101: """
4102:
+4103: X= _assert_all_types( X, pd.DataFrame )
__Pyx_TraceLine(4103,0,__PYX_ERR(0, 4103, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_X, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_X, __pyx_t_1); __pyx_t_1 = 0;
+4104: if columns is not None:
__Pyx_TraceLine(4104,0,__PYX_ERR(0, 4104, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_columns != Py_None); if (__pyx_t_6) { /* … */ goto __pyx_L3; }
+4105: columns = list(columns)
__Pyx_TraceLine(4105,0,__PYX_ERR(0, 4105, __pyx_L1_error)) __pyx_t_1 = PySequence_List(__pyx_v_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_1); __pyx_t_1 = 0;
+4106: if not is_iterable(columns):
__Pyx_TraceLine(4106,0,__PYX_ERR(0, 4106, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_columns}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = (!__pyx_t_6); if (unlikely(__pyx_t_7)) { /* … */ }
+4107: raise TypeError("columns expects an iterable object."
__Pyx_TraceLine(4107,0,__PYX_ERR(0, 4107, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_columns_expects_an_iterable_obje, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 4107, __pyx_L1_error)
+4108: f" got {type (columns).__name__!r}")
__Pyx_TraceLine(4108,0,__PYX_ERR(0, 4108, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_columns)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_1), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+4109: if len(columns ) != len(X.columns):
__Pyx_TraceLine(4109,0,__PYX_ERR(0, 4109, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4109, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4109, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (__pyx_t_8 != __pyx_t_9); if (__pyx_t_7) { /* … */ goto __pyx_L5; }
+4110: warnings.warn("Cannot rename columns with new labels. Expect "
__Pyx_TraceLine(4110,0,__PYX_ERR(0, 4110, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_Cannot_rename_columns_with_new_l); __pyx_t_9 += 90; __Pyx_GIVEREF(__pyx_kp_u_Cannot_rename_columns_with_new_l); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Cannot_rename_columns_with_new_l); /* … */ __Pyx_TraceLine(4110,0,__PYX_ERR(0, 4110, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4111: "a size to be consistent with the columns X."
+4112: f" {len(columns)} and {len(X.columns)} are given."
__Pyx_TraceLine(4112,0,__PYX_ERR(0, 4112, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4112, __pyx_L1_error) __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_8, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_and_2); __pyx_t_9 += 5; __Pyx_GIVEREF(__pyx_kp_u_and_2); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_and_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4112, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_8, 0, ' ', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_are_given); __pyx_t_9 += 11; __Pyx_GIVEREF(__pyx_kp_u_are_given); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_are_given);
4113: )
4114: else :
+4115: X.columns = columns # rename columns
__Pyx_TraceLine(4115,0,__PYX_ERR(0, 4115, __pyx_L1_error)) /*else*/ { if (__Pyx_PyObject_SetAttrStr(__pyx_v_X, __pyx_n_s_columns, __pyx_v_columns) < 0) __PYX_ERR(0, 4115, __pyx_L1_error) } __pyx_L5:;
4116:
+4117: else: columns = list(X.columns)
__Pyx_TraceLine(4117,0,__PYX_ERR(0, 4117, __pyx_L1_error)) /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_4); __pyx_t_4 = 0; } __pyx_L3:;
4118:
+4119: _assert_all_types(name,str, int, float )
__Pyx_TraceLine(4119,0,__PYX_ERR(0, 4119, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_v_name, ((PyObject *)(&PyUnicode_Type)), ((PyObject *)(&PyInt_Type)), ((PyObject *)(&PyFloat_Type))}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 4+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4119, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4120:
4121: # if name is given as indices
4122: # collect the name at that index
+4123: if isinstance (name, (int, float) ) :
__Pyx_TraceLine(4123,0,__PYX_ERR(0, 4123, __pyx_L1_error)) __pyx_t_6 = PyInt_Check(__pyx_v_name); if (!__pyx_t_6) { } else { __pyx_t_7 = __pyx_t_6; goto __pyx_L7_bool_binop_done; } __pyx_t_6 = PyFloat_Check(__pyx_v_name); __pyx_t_7 = __pyx_t_6; __pyx_L7_bool_binop_done:; if (__pyx_t_7) { /* … */ goto __pyx_L6; }
+4124: name = int (name )
__Pyx_TraceLine(4124,0,__PYX_ERR(0, 4124, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4); __pyx_t_4 = 0;
+4125: if name > len(columns):
__Pyx_TraceLine(4125,0,__PYX_ERR(0, 4125, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4125, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyObject_RichCompare(__pyx_v_name, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_7) { /* … */ goto __pyx_L9; }
+4126: warnings.warn ("Name index {name} is out of the columns range."
__Pyx_TraceLine(4126,0,__PYX_ERR(0, 4126, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_warnings); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(4126,0,__PYX_ERR(0, 4126, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Name_index_name_is_out_of_the_co, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_1}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4126, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+4127: f" Max index of columns is {len(columns)}")
__Pyx_TraceLine(4127,0,__PYX_ERR(0, 4127, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4127, __pyx_L1_error) __pyx_t_4 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_9, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
+4128: name = None
__Pyx_TraceLine(4128,0,__PYX_ERR(0, 4128, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_name, Py_None);
4129: else :
+4130: name = columns.pop (name)
__Pyx_TraceLine(4130,0,__PYX_ERR(0, 4130, __pyx_L1_error)) /*else*/ { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_columns, __pyx_n_s_pop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_name}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_2); __pyx_t_2 = 0; } __pyx_L9:;
4131:
+4132: elif isinstance (name, str):
__Pyx_TraceLine(4132,0,__PYX_ERR(0, 4132, __pyx_L1_error)) __pyx_t_7 = PyUnicode_Check(__pyx_v_name); if (__pyx_t_7) { /* … */ } __pyx_L6:;
4133: # find in columns whether a name can be
4134: # found. Note that all name does not need
4135: # to be written completely
4136: # for instance name =depth can retrieved
4137: # ['depth_top, 'depth_bottom'] , in that case
4138: # the first occurence is selected i.e. 'depth_top'
+4139: n = find_by_regex(
__Pyx_TraceLine(4139,0,__PYX_ERR(0, 4139, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_find_by_regex); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(4140,0,__PYX_ERR(0, 4140, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_columns); __Pyx_GIVEREF(__pyx_v_columns); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_columns)) __PYX_ERR(0, 4139, __pyx_L1_error); /* … */ __Pyx_TraceLine(4139,0,__PYX_ERR(0, 4139, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4139, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_n = __pyx_t_11; __pyx_t_11 = 0;
+4140: columns, pattern=fr'{name}', func=re.search)
__pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pattern, __pyx_t_4) < 0) __PYX_ERR(0, 4140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_search); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_func, __pyx_t_11) < 0) __PYX_ERR(0, 4140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
4141:
+4142: if n is not None:
__Pyx_TraceLine(4142,0,__PYX_ERR(0, 4142, __pyx_L1_error)) __pyx_t_7 = (__pyx_v_n != Py_None); if (__pyx_t_7) { /* … */ }
+4143: name = n[0]
__Pyx_TraceLine(4143,0,__PYX_ERR(0, 4143, __pyx_L1_error)) __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_n, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_11); __pyx_t_11 = 0;
4144:
4145: # for consistency , recheck all and let
4146: # a warning to user
+4147: if name not in columns :
__Pyx_TraceLine(4147,0,__PYX_ERR(0, 4147, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_name, __pyx_v_columns, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4147, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+4148: msg = f"Name {name!r} does not match any column names."
__Pyx_TraceLine(4148,0,__PYX_ERR(0, 4148, __pyx_L1_error)) __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_Name); __pyx_t_9 += 5; __Pyx_GIVEREF(__pyx_kp_u_Name); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Name); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_name), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_10; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_does_not_match_any_column_names); __pyx_t_9 += 33; __Pyx_GIVEREF(__pyx_kp_u_does_not_match_any_column_names); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u_does_not_match_any_column_names); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_11, 3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4149: if error =='raise':
__Pyx_TraceLine(4149,0,__PYX_ERR(0, 4149, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4149, __pyx_L1_error) if (unlikely(__pyx_t_7)) { /* … */ }
+4150: raise ValueError (msg)
__Pyx_TraceLine(4150,0,__PYX_ERR(0, 4150, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_msg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4150, __pyx_L1_error)
4151:
+4152: warnings.warn(msg)
__Pyx_TraceLine(4152,0,__PYX_ERR(0, 4152, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_warnings); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_v_msg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+4153: name =None
__Pyx_TraceLine(4153,0,__PYX_ERR(0, 4153, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_name, Py_None);
4154:
4155: # now create a pseudo-depth
4156: # as a range of len X
+4157: if name is None:
__Pyx_TraceLine(4157,0,__PYX_ERR(0, 4157, __pyx_L1_error)) __pyx_t_7 = (__pyx_v_name == Py_None); if (__pyx_t_7) { /* … */ goto __pyx_L13; }
+4158: if error =='raise':
__Pyx_TraceLine(4158,0,__PYX_ERR(0, 4158, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4158, __pyx_L1_error) if (unlikely(__pyx_t_7)) { /* … */ }
+4159: raise ValueError ("Depth column not found in dataframe."
__Pyx_TraceLine(4159,0,__PYX_ERR(0, 4159, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__185, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4159, __pyx_L1_error) /* … */ __pyx_tuple__185 = PyTuple_Pack(1, __pyx_kp_u_Depth_column_not_found_in_datafr); if (unlikely(!__pyx_tuple__185)) __PYX_ERR(0, 4159, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__185); __Pyx_GIVEREF(__pyx_tuple__185);
4160: )
+4161: depth = pd.Series ( np.arange ( len(X)), name ='depth (m)')
__Pyx_TraceLine(4161,0,__PYX_ERR(0, 4161, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_arange); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_9 = PyObject_Length(__pyx_v_X); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4161, __pyx_L1_error) __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_11}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 4161, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_name_2, __pyx_kp_u_depth_m) < 0) __PYX_ERR(0, 4161, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_depth = __pyx_t_11; __pyx_t_11 = 0;
4162: else :
4163: # if depth name exists,
4164: # remove it from X
+4165: depth = X.pop (name )
__Pyx_TraceLine(4165,0,__PYX_ERR(0, 4165, __pyx_L1_error)) /*else*/ { __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_pop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_name}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_depth = __pyx_t_11; __pyx_t_11 = 0; } __pyx_L13:;
4166:
+4167: return X , depth
__Pyx_TraceLine(4167,0,__PYX_ERR(0, 4167, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4167, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_v_X); __Pyx_GIVEREF(__pyx_v_X); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_X)) __PYX_ERR(0, 4167, __pyx_L1_error); __Pyx_INCREF(__pyx_v_depth); __Pyx_GIVEREF(__pyx_v_depth); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_depth)) __PYX_ERR(0, 4167, __pyx_L1_error); __pyx_r = __pyx_t_11; __pyx_t_11 = 0; goto __pyx_L0;
4168:
+4169: def smart_label_classifier (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_150smart_label_classifier(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_149smart_label_classifier, " map smartly the numeric array into a class labels from a map function \n or a given fixed values. \n \n New classes created from the fixed values can be renamed if `labels` \n are supplied. \n \n Parameters \n -------------\n arr: Arraylike 1d, \n array-like whose items are expected to be categorized. \n \n values: float, list of float, \n The threshold item values from which the default categorization must \n be fixed. \n labels: int |str| or List of [str, int], \n The labels values that might be correspond to the fixed values. Note \n that the number of `fixed_labels` might be consistent with the fixed \n `values` plus one, otherwise a ValueError shall raise if `order` is \n set to ``strict``. \n \n order: str, ['soft'|'strict'], default='soft', \n If order is ``strict``, the argument passed to `values` must be self \n contain as item in the `arr`, and raise warning otherwise. \n \n func: callable, optional \n Function to map the given array. If given, values dont need to be \n supply. \n \n raise_warn: bool, default='True'\n Raise warning message if `order=soft` and the fixed `values` are not \n found in the `arr`. Also raise warnings, if `labels` arguments does \n not match the number of class from fixed `values`. \n \n Returns \n ----------\n arr: array-like 1d \n categorized array with the same length as the raw \n \n Examples\n ----------\n >>> import numpy as np\n >>> from gofast.tools.coreutils import smart_label_classifier\n >>> sc = np.arange (0, 7, .5 ) \n >>> smart_label_classifier (sc, values = [1, 3.2 ]) \n array([0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2], dtype=int64)\n >>> # rename labels <=1 : 'l1', ]1; 3.2]: 'l2' and >3.2 :'l3'\n >>> smart_label_classifier (sc, values = [1, 3.2 ], labels =['l1', 'l2', 'l3'])\n >>> array(['l""1', 'l1', 'l1', 'l2', 'l2', 'l2', 'l2', 'l3', 'l3', 'l3', 'l3',\n 'l3', 'l3', 'l3'], dtype=object)\n >>> def f (v): \n if v <=1: return 'l1'\n elif 1< v<=3.2: return \"l2\" \n else : return \"l3\"\n >>> smart_label_classifier (sc, func= f )\n array(['l1', 'l1', 'l1', 'l2', 'l2', 'l2', 'l2', 'l3', 'l3', 'l3', 'l3',\n 'l3', 'l3', 'l3'], dtype=object)\n >>> smart_label_classifier (sc, values = 1.)\n array([0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=int64)\n >>> smart_label_classifier (sc, values = 1., labels='l1') \n array(['l1', 'l1', 'l1', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=object)\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_150smart_label_classifier = {"smart_label_classifier", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_150smart_label_classifier, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_149smart_label_classifier}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_150smart_label_classifier(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_values = 0; PyObject *__pyx_v_labels = 0; PyObject *__pyx_v_order = 0; PyObject *__pyx_v_func = 0; PyObject *__pyx_v_raise_warn = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("smart_label_classifier (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_values,&__pyx_n_s_labels,&__pyx_n_s_order,&__pyx_n_s_func,&__pyx_n_s_raise_warn,0}; PyObject* values[6] = {0,0,0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_149smart_label_classifier(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_values, PyObject *__pyx_v_labels, PyObject *__pyx_v_order, PyObject *__pyx_v_func, PyObject *__pyx_v_raise_warn) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier *__pyx_cur_scope; PyObject *__pyx_v_name = NULL; PyObject *__pyx_v__is_arraylike_1d = NULL; PyObject *__pyx_v_approx_vs = NULL; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_type_error = NULL; PyObject *__pyx_v_diff_v = NULL; PyObject *__pyx_v_ix_v = NULL; PyObject *__pyx_v_vv = NULL; PyObject *__pyx_v_aa = NULL; PyObject *__pyx_v_verb = NULL; PyObject *__pyx_v_arr_ = NULL; PyObject *__pyx_v_dfunc = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__186) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 4169, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("smart_label_classifier", __pyx_f[0], 4169, 0, __PYX_ERR(0, 4169, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_arr); __Pyx_INCREF(__pyx_v_values); __Pyx_INCREF(__pyx_v_labels); __Pyx_INCREF(__pyx_v_func); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __Pyx_AddTraceback("gofast.tools.coreutils.smart_label_classifier", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v__is_arraylike_1d); __Pyx_XDECREF(__pyx_v_approx_vs); __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_type_error); __Pyx_XDECREF(__pyx_v_diff_v); __Pyx_XDECREF(__pyx_v_ix_v); __Pyx_XDECREF(__pyx_v_vv); __Pyx_XDECREF(__pyx_v_aa); __Pyx_XDECREF(__pyx_v_verb); __Pyx_XDECREF(__pyx_v_arr_); __Pyx_XDECREF(__pyx_v_dfunc); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_arr); __Pyx_XDECREF(__pyx_v_values); __Pyx_XDECREF(__pyx_v_labels); __Pyx_XDECREF(__pyx_v_func); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__455 = PyTuple_Pack(21, __pyx_n_s_arr, __pyx_n_s_values, __pyx_n_s_labels, __pyx_n_s_order, __pyx_n_s_func, __pyx_n_s_raise_warn, __pyx_n_s_name_2, __pyx_n_s_is_arraylike_1d, __pyx_n_s_approx_vs, __pyx_n_s_values_2, __pyx_n_s_i, __pyx_n_s_v, __pyx_n_s_type_error, __pyx_n_s_diff_v, __pyx_n_s_ix_v, __pyx_n_s_vv, __pyx_n_s_aa, __pyx_n_s_verb, __pyx_n_s_arr_2, __pyx_n_s_dfunc, __pyx_n_s_d_3); if (unlikely(!__pyx_tuple__455)) __PYX_ERR(0, 4169, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__455); __Pyx_GIVEREF(__pyx_tuple__455); __pyx_codeobj__186 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__455, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_smart_label_classifier, 4169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__186)) __PYX_ERR(0, 4169, __pyx_L1_error) /* … */ __Pyx_TraceLine(4169,0,__PYX_ERR(0, 4169, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_arr, __pyx_n_s_ArrayLike) < 0) __PYX_ERR(0, 4169, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_values, __pyx_kp_s_Union_float_List_float) < 0) __PYX_ERR(0, 4169, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_labels, __pyx_kp_s_Union_int_str_List_str) < 0) __PYX_ERR(0, 4169, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_func, __pyx_n_s_F) < 0) __PYX_ERR(0, 4169, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_150smart_label_classifier, 0, __pyx_n_s_smart_label_classifier, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__186)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__456); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_smart_label_classifier, __pyx_t_5) < 0) __PYX_ERR(0, 4169, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__456 = PyTuple_Pack(5, Py_None, Py_None, ((PyObject*)__pyx_n_u_soft), Py_None, ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__456)) __PYX_ERR(0, 4169, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__456); __Pyx_GIVEREF(__pyx_tuple__456); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier { PyObject_HEAD PyObject *__pyx_v_values_; };
+4170: arr: ArrayLike, values: Union [float, List[float]]= None ,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4171: labels: Union [int, str, List[str]] =None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_soft)));
+4172: order ='soft', func: _F=None, raise_warn=True):
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_values); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_labels); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_order); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_warn); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4169, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "smart_label_classifier") < 0)) __PYX_ERR(0, 4169, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_values = values[1]; __pyx_v_labels = values[2]; __pyx_v_order = values[3]; __pyx_v_func = values[4]; __pyx_v_raise_warn = values[5]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("smart_label_classifier", 0, 1, 6, __pyx_nargs); __PYX_ERR(0, 4169, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.smart_label_classifier", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_149smart_label_classifier(__pyx_self, __pyx_v_arr, __pyx_v_values, __pyx_v_labels, __pyx_v_order, __pyx_v_func, __pyx_v_raise_warn);
4173: """ map smartly the numeric array into a class labels from a map function
4174: or a given fixed values.
4175:
4176: New classes created from the fixed values can be renamed if `labels`
4177: are supplied.
4178:
4179: Parameters
4180: -------------
4181: arr: Arraylike 1d,
4182: array-like whose items are expected to be categorized.
4183:
4184: values: float, list of float,
4185: The threshold item values from which the default categorization must
4186: be fixed.
4187: labels: int |str| or List of [str, int],
4188: The labels values that might be correspond to the fixed values. Note
4189: that the number of `fixed_labels` might be consistent with the fixed
4190: `values` plus one, otherwise a ValueError shall raise if `order` is
4191: set to ``strict``.
4192:
4193: order: str, ['soft'|'strict'], default='soft',
4194: If order is ``strict``, the argument passed to `values` must be self
4195: contain as item in the `arr`, and raise warning otherwise.
4196:
4197: func: callable, optional
4198: Function to map the given array. If given, values dont need to be
4199: supply.
4200:
4201: raise_warn: bool, default='True'
4202: Raise warning message if `order=soft` and the fixed `values` are not
4203: found in the `arr`. Also raise warnings, if `labels` arguments does
4204: not match the number of class from fixed `values`.
4205:
4206: Returns
4207: ----------
4208: arr: array-like 1d
4209: categorized array with the same length as the raw
4210:
4211: Examples
4212: ----------
4213: >>> import numpy as np
4214: >>> from gofast.tools.coreutils import smart_label_classifier
4215: >>> sc = np.arange (0, 7, .5 )
4216: >>> smart_label_classifier (sc, values = [1, 3.2 ])
4217: array([0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2], dtype=int64)
4218: >>> # rename labels <=1 : 'l1', ]1; 3.2]: 'l2' and >3.2 :'l3'
4219: >>> smart_label_classifier (sc, values = [1, 3.2 ], labels =['l1', 'l2', 'l3'])
4220: >>> array(['l1', 'l1', 'l1', 'l2', 'l2', 'l2', 'l2', 'l3', 'l3', 'l3', 'l3',
4221: 'l3', 'l3', 'l3'], dtype=object)
4222: >>> def f (v):
4223: if v <=1: return 'l1'
4224: elif 1< v<=3.2: return "l2"
4225: else : return "l3"
4226: >>> smart_label_classifier (sc, func= f )
4227: array(['l1', 'l1', 'l1', 'l2', 'l2', 'l2', 'l2', 'l3', 'l3', 'l3', 'l3',
4228: 'l3', 'l3', 'l3'], dtype=object)
4229: >>> smart_label_classifier (sc, values = 1.)
4230: array([0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=int64)
4231: >>> smart_label_classifier (sc, values = 1., labels='l1')
4232: array(['l1', 'l1', 'l1', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=object)
4233:
4234: """
+4235: name =None
__Pyx_TraceLine(4235,0,__PYX_ERR(0, 4235, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_name = Py_None;
+4236: from .validator import _is_arraylike_1d
__Pyx_TraceLine(4236,0,__PYX_ERR(0, 4236, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_is_arraylike_1d); __Pyx_GIVEREF(__pyx_n_s_is_arraylike_1d); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_is_arraylike_1d)) __PYX_ERR(0, 4236, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_validator, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_is_arraylike_1d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v__is_arraylike_1d = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+4237: if hasattr(arr, "name") and isinstance (arr, pd.Series):
__Pyx_TraceLine(4237,0,__PYX_ERR(0, 4237, __pyx_L1_error)) __pyx_t_4 = __Pyx_HasAttr(__pyx_v_arr, __pyx_n_u_name_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 4237, __pyx_L1_error) if (__pyx_t_4) { } else { __pyx_t_3 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Series); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4237, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_v_arr, __pyx_t_1); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 4237, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_3) { /* … */ }
+4238: name = arr.name
__Pyx_TraceLine(4238,0,__PYX_ERR(0, 4238, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_1); __pyx_t_1 = 0;
4239:
+4240: arr= np.array (arr)
__Pyx_TraceLine(4240,0,__PYX_ERR(0, 4240, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_1); __pyx_t_1 = 0;
4241:
+4242: if not _is_arraylike_1d(arr):
__Pyx_TraceLine(4242,0,__PYX_ERR(0, 4242, __pyx_L1_error)) __Pyx_INCREF(__pyx_v__is_arraylike_1d); __pyx_t_5 = __pyx_v__is_arraylike_1d; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_arr}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4242, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_4 = (!__pyx_t_3); if (unlikely(__pyx_t_4)) { /* … */ }
+4243: raise TypeError ("Expects a one-dimensional array, got array with"
__Pyx_TraceLine(4243,0,__PYX_ERR(0, 4243, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expects_a_one_dimensional_array, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 4243, __pyx_L1_error)
+4244: f" shape {arr.shape }")
__Pyx_TraceLine(4244,0,__PYX_ERR(0, 4244, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4245:
+4246: if isinstance (values, str):
__Pyx_TraceLine(4246,0,__PYX_ERR(0, 4246, __pyx_L1_error)) __pyx_t_4 = PyUnicode_Check(__pyx_v_values); if (__pyx_t_4) { /* … */ }
+4247: values = str2columns(values )
__Pyx_TraceLine(4247,0,__PYX_ERR(0, 4247, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_values}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_values, __pyx_t_5); __pyx_t_5 = 0;
+4248: if values is not None:
__Pyx_TraceLine(4248,0,__PYX_ERR(0, 4248, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_values != Py_None); if (__pyx_t_4) { /* … */ }
+4249: values = is_iterable(values, parse_string =True, transform = True )
__Pyx_TraceLine(4249,0,__PYX_ERR(0, 4249, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_values); __Pyx_GIVEREF(__pyx_v_values); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_values)) __PYX_ERR(0, 4249, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parse_string, Py_True) < 0) __PYX_ERR(0, 4249, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 4249, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_values, __pyx_t_7); __pyx_t_7 = 0;
4250: # if (values is not None
4251: # and not is_iterable( values)):
4252: # values =[values ]
4253:
+4254: if values is not None:
__Pyx_TraceLine(4254,0,__PYX_ERR(0, 4254, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_values != Py_None); if (__pyx_t_4) { /* … */ }
+4255: approx_vs=list()
__Pyx_TraceLine(4255,0,__PYX_ERR(0, 4255, __pyx_L1_error)) __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4255, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_approx_vs = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0;
+4256: values_ =np.zeros ((len(values), ), dtype =float )
__Pyx_TraceLine(4256,0,__PYX_ERR(0, 4256, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4256, __pyx_L1_error) __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7)) __PYX_ERR(0, 4256, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1)) __PYX_ERR(0, 4256, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 4256, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_5); __pyx_cur_scope->__pyx_v_values_ = __pyx_t_5; __pyx_t_5 = 0;
+4257: for i, v in enumerate (values ) :
__Pyx_TraceLine(4257,0,__PYX_ERR(0, 4257, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_5 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_values)) || PyTuple_CheckExact(__pyx_v_values)) { __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4257, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4257, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 4257, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4257, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_7); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 4257, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_9(__pyx_t_1); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4257, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_5); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_5, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4257, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = __pyx_t_7; __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(4257,0,__PYX_ERR(0, 4257, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+4258: try : v= float (v)
__Pyx_TraceLine(4258,0,__PYX_ERR(0, 4258, __pyx_L1_error)) { /*try:*/ { __pyx_t_7 = __Pyx_PyNumber_Float(__pyx_v_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4258, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L19_try_end; __pyx_L12_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L14_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12); goto __pyx_L1_error; __pyx_L19_try_end:; }
+4259: except TypeError as type_error :
__Pyx_TraceLine(4259,0,__PYX_ERR(0, 4259, __pyx_L14_except_error)) __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_6) { __Pyx_AddTraceback("gofast.tools.coreutils.smart_label_classifier", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_13) < 0) __PYX_ERR(0, 4259, __pyx_L14_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_t_2); __pyx_v_type_error = __pyx_t_2; /*try:*/ { /* … */ __Pyx_TraceLine(4259,0,__PYX_ERR(0, 4259, __pyx_L25_error)) /*finally:*/ { __pyx_L25_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __Pyx_XGOTREF(__pyx_t_24); __Pyx_XGOTREF(__pyx_t_25); __Pyx_XGOTREF(__pyx_t_26); __pyx_t_6 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename; { __Pyx_DECREF(__pyx_v_type_error); __pyx_v_type_error = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_24); __Pyx_XGIVEREF(__pyx_t_25); __Pyx_XGIVEREF(__pyx_t_26); __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26); } __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23); __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20; goto __pyx_L14_except_error; } } } goto __pyx_L14_except_error;
+4260: raise TypeError (
__Pyx_TraceLine(4260,0,__PYX_ERR(0, 4260, __pyx_L25_error)) __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_18); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4260, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_Raise(__pyx_t_14, 0, 0, 0); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __PYX_ERR(0, 4260, __pyx_L25_error) }
+4261: f"Value {v} must be a valid number." + str(type_error))
__Pyx_TraceLine(4261,0,__PYX_ERR(0, 4261, __pyx_L25_error)) __pyx_t_14 = PyTuple_New(3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4261, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = 0; __pyx_t_16 = 127; __Pyx_INCREF(__pyx_kp_u_Value); __pyx_t_15 += 6; __Pyx_GIVEREF(__pyx_kp_u_Value); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_kp_u_Value); __pyx_t_17 = __Pyx_PyObject_FormatSimple(__pyx_v_v, __pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4261, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) : __pyx_t_16; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_17); __pyx_t_17 = 0; __Pyx_INCREF(__pyx_kp_u_must_be_a_valid_number); __pyx_t_15 += 24; __Pyx_GIVEREF(__pyx_kp_u_must_be_a_valid_number); PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_kp_u_must_be_a_valid_number); __pyx_t_17 = __Pyx_PyUnicode_Join(__pyx_t_14, 3, __pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4261, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_Str(__pyx_v_type_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4261, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_18 = PyNumber_Add(__pyx_t_17, __pyx_t_14); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4261, __pyx_L25_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+4262: diff_v = np.abs (arr[~np.isnan(arr)] - v )
__Pyx_TraceLine(4262,0,__PYX_ERR(0, 4262, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_abs); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_isnan); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_v_arr}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __pyx_t_18 = PyNumber_Invert(__pyx_t_2); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_t_18); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = PyNumber_Subtract(__pyx_t_2, __pyx_v_v); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_18}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_diff_v, __pyx_t_13); __pyx_t_13 = 0;
4263:
+4264: ix_v = np.argmin (diff_v)
__Pyx_TraceLine(4264,0,__PYX_ERR(0, 4264, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_argmin); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_diff_v}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __Pyx_XDECREF_SET(__pyx_v_ix_v, __pyx_t_13); __pyx_t_13 = 0;
+4265: if order =='strict' and diff_v [ix_v]!=0. :
__Pyx_TraceLine(4265,0,__PYX_ERR(0, 4265, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_strict, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4265, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L32_bool_binop_done; } __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_v_diff_v, __pyx_v_ix_v); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_3 = (__Pyx_PyFloat_BoolNeObjC(__pyx_t_13, __pyx_float_0_, 0., 0, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4265, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_4 = __pyx_t_3; __pyx_L32_bool_binop_done:; if (unlikely(__pyx_t_4)) { /* … */ }
+4266: raise ValueError (
__Pyx_TraceLine(4266,0,__PYX_ERR(0, 4266, __pyx_L1_error)) __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_18); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_Raise(__pyx_t_13, 0, 0, 0); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __PYX_ERR(0, 4266, __pyx_L1_error)
+4267: f" Value {v} is missing the array. {v} must be an item"
__Pyx_TraceLine(4267,0,__PYX_ERR(0, 4267, __pyx_L1_error)) __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_15 = 0; __pyx_t_16 = 127; __Pyx_INCREF(__pyx_kp_u_Value_2); __pyx_t_15 += 7; __Pyx_GIVEREF(__pyx_kp_u_Value_2); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_kp_u_Value_2); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_v, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u_is_missing_the_array); __pyx_t_15 += 23; __Pyx_GIVEREF(__pyx_kp_u_is_missing_the_array); PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_kp_u_is_missing_the_array); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_v, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_15 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u_must_be_an_item_existing_in_the); __pyx_t_15 += 97; __Pyx_GIVEREF(__pyx_kp_u_must_be_an_item_existing_in_the); PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_kp_u_must_be_an_item_existing_in_the); __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_13, 5, __pyx_t_15, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4267, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
4268: " existing in the array or turn order to 'soft' for"
4269: " approximate values selectors. ")
4270:
4271: # skip NaN in the case array contains NaN values
+4272: values_[i] = arr[~np.isnan(arr)][ix_v]
__Pyx_TraceLine(4272,0,__PYX_ERR(0, 4272, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_n_s_np); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_n_s_isnan); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_18)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_v_arr}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyNumber_Invert(__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_t_13, __pyx_v_ix_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_values_, __pyx_v_i, __pyx_t_7) < 0))) __PYX_ERR(0, 4272, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4273:
+4274: if diff_v [ix_v]!=0.:
__Pyx_TraceLine(4274,0,__PYX_ERR(0, 4274, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_diff_v, __pyx_v_ix_v); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = (__Pyx_PyFloat_BoolNeObjC(__pyx_t_7, __pyx_float_0_, 0., 0, 0)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 4274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_4) { /* … */ }
+4275: approx_vs.append ((v, arr[~np.isnan(arr)][ix_v]))
__Pyx_TraceLine(4275,0,__PYX_ERR(0, 4275, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_isnan); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_18))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_v_arr}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __pyx_t_18 = PyNumber_Invert(__pyx_t_7); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_t_18); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyObject_GetItem(__pyx_t_7, __pyx_v_ix_v); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_v); __Pyx_GIVEREF(__pyx_v_v); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_v)) __PYX_ERR(0, 4275, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_18); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_18)) __PYX_ERR(0, 4275, __pyx_L1_error); __pyx_t_18 = 0; __pyx_t_27 = __Pyx_PyList_Append(__pyx_v_approx_vs, __pyx_t_7); if (unlikely(__pyx_t_27 == ((int)-1))) __PYX_ERR(0, 4275, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
4276:
+4277: if len(approx_vs) !=0 and raise_warn:
__Pyx_TraceLine(4277,0,__PYX_ERR(0, 4277, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyList_GET_SIZE(__pyx_v_approx_vs); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4277, __pyx_L1_error) __pyx_t_3 = (__pyx_t_8 != 0); if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L37_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_raise_warn); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4277, __pyx_L1_error) __pyx_t_4 = __pyx_t_3; __pyx_L37_bool_binop_done:; if (__pyx_t_4) { /* … */ }
+4278: vv, aa = zip (*approx_vs)
__Pyx_TraceLine(4278,0,__PYX_ERR(0, 4278, __pyx_L1_error)) __pyx_t_5 = PySequence_Tuple(__pyx_v_approx_vs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 4278, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_7 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_18 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4278, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_28 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_18); index = 0; __pyx_t_5 = __pyx_t_28(__pyx_t_18); if (unlikely(!__pyx_t_5)) goto __pyx_L39_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_7 = __pyx_t_28(__pyx_t_18); if (unlikely(!__pyx_t_7)) goto __pyx_L39_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); if (__Pyx_IternextUnpackEndCheck(__pyx_t_28(__pyx_t_18), 2) < 0) __PYX_ERR(0, 4278, __pyx_L1_error) __pyx_t_28 = NULL; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; goto __pyx_L40_unpacking_done; __pyx_L39_unpacking_failed:; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_28 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 4278, __pyx_L1_error) __pyx_L40_unpacking_done:; } __pyx_v_vv = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_aa = __pyx_t_7; __pyx_t_7 = 0;
+4279: verb ="are" if len(vv)>1 else "is"
__Pyx_TraceLine(4279,0,__PYX_ERR(0, 4279, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_vv); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4279, __pyx_L1_error) __pyx_t_4 = (__pyx_t_8 > 1); if (__pyx_t_4) { __Pyx_INCREF(__pyx_n_u_are); __pyx_t_1 = __pyx_n_u_are; } else { __Pyx_INCREF(__pyx_n_u_is_2); __pyx_t_1 = __pyx_n_u_is_2; } __pyx_v_verb = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4280: warnings.warn(f"Values {vv} are missing in the array. {aa} {verb}"
__Pyx_TraceLine(4280,0,__PYX_ERR(0, 4280, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_warnings); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_warn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = 0; __pyx_t_16 = 127; __Pyx_INCREF(__pyx_kp_u_Values); __pyx_t_8 += 7; __Pyx_GIVEREF(__pyx_kp_u_Values); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u_Values); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_vv, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u_are_missing_in_the_array); __pyx_t_8 += 27; __Pyx_GIVEREF(__pyx_kp_u_are_missing_in_the_array); PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_kp_u_are_missing_in_the_array); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_aa, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_kp_u__14); __pyx_t_18 = __Pyx_PyUnicode_Unicode(__pyx_v_verb); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_7, 5, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u_approximatively_used_for_substi); __pyx_t_8 += 43; __Pyx_GIVEREF(__pyx_kp_u_approximatively_used_for_substi); PyTuple_SET_ITEM(__pyx_t_7, 6, __pyx_kp_u_approximatively_used_for_substi); /* … */ __Pyx_TraceLine(4280,0,__PYX_ERR(0, 4280, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyUnicode_Join(__pyx_t_7, 9, __pyx_t_8, __pyx_t_16); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_18}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4280, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+4281: f" approximatively used for substituting the {vv}.")
__Pyx_TraceLine(4281,0,__PYX_ERR(0, 4281, __pyx_L1_error)) __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_v_vv, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_16 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) > __pyx_t_16) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) : __pyx_t_16; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18); __Pyx_GIVEREF(__pyx_t_18); PyTuple_SET_ITEM(__pyx_t_7, 7, __pyx_t_18); __pyx_t_18 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_7, 8, __pyx_kp_u__26);
+4282: arr_ = arr.copy ()
__Pyx_TraceLine(4282,0,__PYX_ERR(0, 4282, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_18 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_18)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_19, 0+__pyx_t_19); __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_arr_ = __pyx_t_1; __pyx_t_1 = 0;
4283:
4284: ####
+4285: if (func is None and values is None ):
__Pyx_TraceLine(4285,0,__PYX_ERR(0, 4285, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_func == Py_None); if (__pyx_t_3) { } else { __pyx_t_4 = __pyx_t_3; goto __pyx_L42_bool_binop_done; } __pyx_t_3 = (__pyx_v_values == Py_None); __pyx_t_4 = __pyx_t_3; __pyx_L42_bool_binop_done:; if (unlikely(__pyx_t_4)) { /* … */ }
+4286: raise TypeError ("'ufunc' cannot be None when the values are not given")
__Pyx_TraceLine(4286,0,__PYX_ERR(0, 4286, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__187, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4286, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4286, __pyx_L1_error) /* … */ __pyx_tuple__187 = PyTuple_Pack(1, __pyx_kp_u_ufunc_cannot_be_None_when_the_v); if (unlikely(!__pyx_tuple__187)) __PYX_ERR(0, 4286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__187); __Pyx_GIVEREF(__pyx_tuple__187);
4287:
+4288: dfunc =None
__Pyx_TraceLine(4288,0,__PYX_ERR(0, 4288, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_dfunc = Py_None;
4289:
+4290: if values is not None:
__Pyx_TraceLine(4290,0,__PYX_ERR(0, 4290, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_values != Py_None); if (__pyx_t_4) { /* … */ }
+4291: dfunc = lambda k : _smart_mapper (k, kr = values_ )
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22smart_label_classifier_lambda14(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22smart_label_classifier_lambda14 = {"lambda14", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22smart_label_classifier_lambda14, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22smart_label_classifier_lambda14(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_k = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda14 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_k)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4291, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda14") < 0)) __PYX_ERR(0, 4291, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_k = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda14", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4291, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.smart_label_classifier.lambda14", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda14(__pyx_self, __pyx_v_k);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda14(PyObject *__pyx_self, PyObject *__pyx_v_k) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_13_smart_label_classifier *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda14", __pyx_f[0], 4291, 0, __PYX_ERR(0, 4291, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_smart_mapper); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_v_k);
__Pyx_GIVEREF(__pyx_v_k);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_k)) __PYX_ERR(0, 4291, __pyx_L1_error);
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (unlikely(!__pyx_cur_scope->__pyx_v_values_)) { __Pyx_RaiseClosureNameError("values_"); __PYX_ERR(0, 4291, __pyx_L1_error) }
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_kr, __pyx_cur_scope->__pyx_v_values_) < 0) __PYX_ERR(0, 4291, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.smart_label_classifier.lambda14", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(4291,0,__PYX_ERR(0, 4291, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22smart_label_classifier_lambda14, 0, __pyx_n_s_smart_label_classifier_locals_la, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4291, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF_SET(__pyx_v_dfunc, __pyx_t_1);
__pyx_t_1 = 0;
+4292: func = func or dfunc
__Pyx_TraceLine(4292,0,__PYX_ERR(0, 4292, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_func); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 4292, __pyx_L1_error) if (!__pyx_t_4) { } else { __Pyx_INCREF(__pyx_v_func); __pyx_t_1 = __pyx_v_func; goto __pyx_L45_bool_binop_done; } __Pyx_INCREF(__pyx_v_dfunc); __pyx_t_1 = __pyx_v_dfunc; __pyx_L45_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_func, __pyx_t_1); __pyx_t_1 = 0;
4293:
4294: # func_vectorized =np.vectorize(func )
4295: # arr_ = func_vectorized( arr )
+4296: arr_ = pd.Series (arr_, name ='temp').map (func).values
__Pyx_TraceLine(4296,0,__PYX_ERR(0, 4296, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Series); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_arr_); __Pyx_GIVEREF(__pyx_v_arr_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_arr_)) __PYX_ERR(0, 4296, __pyx_L1_error); __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_name_2, __pyx_n_u_temp) < 0) __PYX_ERR(0, 4296, __pyx_L1_error) __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_map); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_v_func}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_values); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_arr_, __pyx_t_7); __pyx_t_7 = 0;
4297:
+4298: d={}
__Pyx_TraceLine(4298,0,__PYX_ERR(0, 4298, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_v_d = __pyx_t_7; __pyx_t_7 = 0;
+4299: if labels is not None:
__Pyx_TraceLine(4299,0,__PYX_ERR(0, 4299, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_labels != Py_None); if (__pyx_t_4) { /* … */ }
+4300: labels = is_iterable(labels, parse_string=True, transform =True )
__Pyx_TraceLine(4300,0,__PYX_ERR(0, 4300, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_labels); __Pyx_GIVEREF(__pyx_v_labels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_labels)) __PYX_ERR(0, 4300, __pyx_L1_error); __pyx_t_13 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_parse_string, Py_True) < 0) __PYX_ERR(0, 4300, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 4300, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, __pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF_SET(__pyx_v_labels, __pyx_t_5); __pyx_t_5 = 0;
4301: # if isinstance (labels, str):
4302: # labels = str2columns(labels )
+4303: labels, d = _assert_labels_from_values (
__Pyx_TraceLine(4303,0,__PYX_ERR(0, 4303, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_assert_labels_from_values); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(4303,0,__PYX_ERR(0, 4303, __pyx_L1_error)) __pyx_t_13 = PyTuple_New(4); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_v_arr_); __Pyx_GIVEREF(__pyx_v_arr_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_arr_)) __PYX_ERR(0, 4303, __pyx_L1_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values_); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_values_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_cur_scope->__pyx_v_values_)) __PYX_ERR(0, 4303, __pyx_L1_error); __Pyx_INCREF(__pyx_v_labels); __Pyx_GIVEREF(__pyx_v_labels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_v_labels)) __PYX_ERR(0, 4303, __pyx_L1_error); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_v_d)) __PYX_ERR(0, 4303, __pyx_L1_error); /* … */ __Pyx_TraceLine(4303,0,__PYX_ERR(0, 4303, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_13, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) { PyObject* sequence = __pyx_t_7; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 4303, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_13 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_13); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_13 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); #endif __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4303, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_28 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_1 = __pyx_t_28(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L48_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_13 = __pyx_t_28(__pyx_t_5); if (unlikely(!__pyx_t_13)) goto __pyx_L48_unpacking_failed; __Pyx_GOTREF(__pyx_t_13); if (__Pyx_IternextUnpackEndCheck(__pyx_t_28(__pyx_t_5), 2) < 0) __PYX_ERR(0, 4303, __pyx_L1_error) __pyx_t_28 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L49_unpacking_done; __pyx_L48_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_28 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 4303, __pyx_L1_error) __pyx_L49_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_labels, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_13); __pyx_t_13 = 0;
+4304: arr_, values_ , labels , d, raise_warn= raise_warn , order =order
__Pyx_TraceLine(4304,0,__PYX_ERR(0, 4304, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_values_)) { __Pyx_RaiseUnboundLocalError("values_"); __PYX_ERR(0, 4304, __pyx_L1_error) } /* … */ __Pyx_TraceLine(4304,0,__PYX_ERR(0, 4304, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_raise_warn, __pyx_v_raise_warn) < 0) __PYX_ERR(0, 4304, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_order, __pyx_v_order) < 0) __PYX_ERR(0, 4304, __pyx_L1_error)
4305: )
4306:
+4307: arr_ = arr_ if labels is None else (
__Pyx_TraceLine(4307,0,__PYX_ERR(0, 4307, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_labels == Py_None); if (__pyx_t_4) { __Pyx_INCREF(__pyx_v_arr_); __pyx_t_7 = __pyx_v_arr_; } else {
+4308: pd.Series (arr_, name = name or 'tname').map(d))
__Pyx_TraceLine(4308,0,__PYX_ERR(0, 4308, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_arr_); __Pyx_GIVEREF(__pyx_v_arr_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_arr_)) __PYX_ERR(0, 4308, __pyx_L1_error); __pyx_t_18 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4308, __pyx_L1_error) if (!__pyx_t_3) { } else { __Pyx_INCREF(__pyx_v_name); __pyx_t_2 = __pyx_v_name; goto __pyx_L50_bool_binop_done; } __Pyx_INCREF(__pyx_n_u_tname); __pyx_t_2 = __pyx_n_u_tname; __pyx_L50_bool_binop_done:; if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_name_2, __pyx_t_2) < 0) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_18); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_map); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_19 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_18))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_18); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_18); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_18, function); __pyx_t_19 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_d}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_18, __pyx_callargs+1-__pyx_t_19, 1+__pyx_t_19); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4308, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; } __pyx_t_7 = __pyx_t_13; __pyx_t_13 = 0; } __Pyx_DECREF_SET(__pyx_v_arr_, __pyx_t_7); __pyx_t_7 = 0;
4309:
4310: # if name is None: # for consisteny if labels is None
+4311: arr_= (arr_.values if labels is not None else arr_
__Pyx_TraceLine(4311,0,__PYX_ERR(0, 4311, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_labels != Py_None); if (__pyx_t_3) { __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr_, __pyx_n_s_values); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_13 = __pyx_t_18; __pyx_t_18 = 0; } else { __Pyx_INCREF(__pyx_v_arr_); __pyx_t_13 = __pyx_v_arr_; } __pyx_t_7 = __pyx_t_13; __pyx_t_13 = 0; } else {
+4312: ) if name is None else pd.Series (arr_, name = name )
__Pyx_TraceLine(4312,0,__PYX_ERR(0, 4312, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_name == Py_None); if (__pyx_t_4) { /* … */ __Pyx_TraceLine(4312,0,__PYX_ERR(0, 4312, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_pd); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_Series); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_v_arr_); __Pyx_GIVEREF(__pyx_v_arr_); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_arr_)) __PYX_ERR(0, 4312, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_name_2, __pyx_v_name) < 0) __PYX_ERR(0, 4312, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4312, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __pyx_t_1; __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_arr_, __pyx_t_7); __pyx_t_7 = 0;
4313:
+4314: return arr_
__Pyx_TraceLine(4314,0,__PYX_ERR(0, 4314, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arr_); __pyx_r = __pyx_v_arr_; goto __pyx_L0;
4315:
+4316: def _assert_labels_from_values (ar, values , labels , d={},
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_326__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 4316, 0, __PYX_ERR(0, 4316, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(4317,0,__PYX_ERR(0, 4317, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4316, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_d);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_d);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self)->__pyx_arg_d)) __PYX_ERR(0, 4316, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_True));
__Pyx_GIVEREF(((PyObject *)Py_True));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_True))) __PYX_ERR(0, 4316, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_n_u_soft));
__Pyx_GIVEREF(((PyObject*)__pyx_n_u_soft));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject*)__pyx_n_u_soft))) __PYX_ERR(0, 4316, __pyx_L1_error);
/* … */
__Pyx_TraceLine(4316,0,__PYX_ERR(0, 4316, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4316, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 4316, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 4316, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_152_assert_labels_from_values(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_151_assert_labels_from_values, " Isolated part of the :func:`~.smart_label_classifier`");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_152_assert_labels_from_values = {"_assert_labels_from_values", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_152_assert_labels_from_values, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_151_assert_labels_from_values};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_152_assert_labels_from_values(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_ar = 0;
PyObject *__pyx_v_values = 0;
PyObject *__pyx_v_labels = 0;
PyObject *__pyx_v_d = 0;
PyObject *__pyx_v_raise_warn = 0;
PyObject *__pyx_v_order = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("_assert_labels_from_values (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ar,&__pyx_n_s_values,&__pyx_n_s_labels,&__pyx_n_s_d_3,&__pyx_n_s_raise_warn,&__pyx_n_s_order,0};
PyObject* values[6] = {0,0,0,0,0,0};
__pyx_defaults10 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_self);
values[3] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_d);
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_soft)));
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ar)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4316, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_values)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[1]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4316, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("_assert_labels_from_values", 0, 3, 6, 1); __PYX_ERR(0, 4316, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_labels)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[2]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4316, __pyx_L3_error)
else {
__Pyx_RaiseArgtupleInvalid("_assert_labels_from_values", 0, 3, 6, 2); __PYX_ERR(0, 4316, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3);
if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4316, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_warn);
if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4316, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 5:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_order);
if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4316, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_assert_labels_from_values") < 0)) __PYX_ERR(0, 4316, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_ar = values[0];
__pyx_v_values = values[1];
__pyx_v_labels = values[2];
__pyx_v_d = values[3];
__pyx_v_raise_warn = values[4];
__pyx_v_order = values[5];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("_assert_labels_from_values", 0, 3, 6, __pyx_nargs); __PYX_ERR(0, 4316, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils._assert_labels_from_values", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_151_assert_labels_from_values(__pyx_self, __pyx_v_ar, __pyx_v_values, __pyx_v_labels, __pyx_v_d, __pyx_v_raise_warn, __pyx_v_order);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_151_assert_labels_from_values(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ar, PyObject *__pyx_v_values, PyObject *__pyx_v_labels, PyObject *__pyx_v_d, PyObject *__pyx_v_raise_warn, PyObject *__pyx_v_order) {
PyObject *__pyx_v__check_consistency_size = NULL;
PyObject *__pyx_v_nlabels = NULL;
PyObject *__pyx_v_verb = NULL;
PyObject *__pyx_v_msg = NULL;
PyObject *__pyx_v_ur_classes = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__188)
__Pyx_TraceCall("_assert_labels_from_values", __pyx_f[0], 4316, 0, __PYX_ERR(0, 4316, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_labels);
__Pyx_INCREF(__pyx_v_d);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_AddTraceback("gofast.tools.coreutils._assert_labels_from_values", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v__check_consistency_size);
__Pyx_XDECREF(__pyx_v_nlabels);
__Pyx_XDECREF(__pyx_v_verb);
__Pyx_XDECREF(__pyx_v_msg);
__Pyx_XDECREF(__pyx_v_ur_classes);
__Pyx_XDECREF(__pyx_v_labels);
__Pyx_XDECREF(__pyx_v_d);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__457 = PyTuple_Pack(11, __pyx_n_s_ar, __pyx_n_s_values, __pyx_n_s_labels, __pyx_n_s_d_3, __pyx_n_s_raise_warn, __pyx_n_s_order, __pyx_n_s_check_consistency_size, __pyx_n_s_nlabels, __pyx_n_s_verb, __pyx_n_s_msg, __pyx_n_s_ur_classes); if (unlikely(!__pyx_tuple__457)) __PYX_ERR(0, 4316, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__457);
__Pyx_GIVEREF(__pyx_tuple__457);
/* … */
__Pyx_TraceLine(4316,0,__PYX_ERR(0, 4316, __pyx_L1_error))
__pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_152_assert_labels_from_values, 0, __pyx_n_s_assert_labels_from_values, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__188)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4316, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_5, sizeof(__pyx_defaults10), 1)) __PYX_ERR(0, 4316, __pyx_L1_error)
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4316, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_Defaults(__pyx_defaults10, __pyx_t_5)->__pyx_arg_d = __pyx_t_2;
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
__Pyx_CyFunction_SetDefaultsGetter(__pyx_t_5, __pyx_pf_6gofast_5tools_9coreutils_326__defaults__);
if (PyDict_SetItem(__pyx_d, __pyx_n_s_assert_labels_from_values, __pyx_t_5) < 0) __PYX_ERR(0, 4316, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_codeobj__188 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__457, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_assert_labels_from_values, 4316, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__188)) __PYX_ERR(0, 4316, __pyx_L1_error)
4317: raise_warn= True , order ='soft'):
4318: """ Isolated part of the :func:`~.smart_label_classifier`"""
+4319: from .validator import _check_consistency_size
__Pyx_TraceLine(4319,0,__PYX_ERR(0, 4319, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_check_consistency_size); __Pyx_GIVEREF(__pyx_n_s_check_consistency_size); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_check_consistency_size)) __PYX_ERR(0, 4319, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_validator, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_check_consistency_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v__check_consistency_size = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4320:
+4321: nlabels = list(np.unique (ar))
__Pyx_TraceLine(4321,0,__PYX_ERR(0, 4321, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unique); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_ar}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4321, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_nlabels = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+4322: if not is_iterable(labels):
__Pyx_TraceLine(4322,0,__PYX_ERR(0, 4322, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_labels}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4322, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ }
+4323: labels =[labels]
__Pyx_TraceLine(4323,0,__PYX_ERR(0, 4323, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4323, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_labels); __Pyx_GIVEREF(__pyx_v_labels); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_labels)) __PYX_ERR(0, 4323, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_labels, __pyx_t_3); __pyx_t_3 = 0;
+4324: if not _check_consistency_size(nlabels, labels, error ='ignore'):
__Pyx_TraceLine(4324,0,__PYX_ERR(0, 4324, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_nlabels); __Pyx_GIVEREF(__pyx_v_nlabels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_nlabels)) __PYX_ERR(0, 4324, __pyx_L1_error); __Pyx_INCREF(__pyx_v_labels); __Pyx_GIVEREF(__pyx_v_labels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_labels)) __PYX_ERR(0, 4324, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_error, __pyx_n_u_ignore) < 0) __PYX_ERR(0, 4324, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v__check_consistency_size, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4324, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4324, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = (!__pyx_t_6); if (__pyx_t_5) { /* … */ }
+4325: if order=='strict':
__Pyx_TraceLine(4325,0,__PYX_ERR(0, 4325, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_order, __pyx_n_u_strict, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4325, __pyx_L1_error) if (unlikely(__pyx_t_5)) { /* … */ }
+4326: verb= "were" if len (labels) > 1 else "was"
__Pyx_TraceLine(4326,0,__PYX_ERR(0, 4326, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_labels); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4326, __pyx_L1_error) __pyx_t_5 = (__pyx_t_7 > 1); if (__pyx_t_5) { __Pyx_INCREF(__pyx_n_u_were); __pyx_t_1 = __pyx_n_u_were; } else { __Pyx_INCREF(__pyx_n_u_was); __pyx_t_1 = __pyx_n_u_was; } __pyx_v_verb = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4327: raise TypeError (
__Pyx_TraceLine(4327,0,__PYX_ERR(0, 4327, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4327, __pyx_L1_error)
+4328: "Expect {len(nlabels)} labels for the {len(values)} values"
__Pyx_TraceLine(4328,0,__PYX_ERR(0, 4328, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Expect_len_nlabels_labels_for_th); __pyx_t_7 += 68; __Pyx_GIVEREF(__pyx_kp_u_Expect_len_nlabels_labels_for_th); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Expect_len_nlabels_labels_for_th); /* … */ __Pyx_TraceLine(4328,0,__PYX_ERR(0, 4328, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+4329: f" renaming. {len(labels)} {verb} given.")
__Pyx_TraceLine(4329,0,__PYX_ERR(0, 4329, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_labels); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4329, __pyx_L1_error) __pyx_t_2 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_9, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_7 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14); __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_verb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_given); __pyx_t_7 += 7; __Pyx_GIVEREF(__pyx_kp_u_given); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_given);
4330:
+4331: verb ="s are" if len(values)>1 else " is"
__Pyx_TraceLine(4331,0,__PYX_ERR(0, 4331, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4331, __pyx_L1_error) __pyx_t_5 = (__pyx_t_7 > 1); if (__pyx_t_5) { __Pyx_INCREF(__pyx_kp_u_s_are); __pyx_t_1 = __pyx_kp_u_s_are; } else { __Pyx_INCREF(__pyx_kp_u_is); __pyx_t_1 = __pyx_kp_u_is; } __pyx_v_verb = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4332: msg = (f"{len(values)} value{verb} passed. Labels for"
__Pyx_TraceLine(4332,0,__PYX_ERR(0, 4332, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = 127; __pyx_t_9 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4332, __pyx_L1_error) __pyx_t_2 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_9, 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_value_2); __pyx_t_7 += 6; __Pyx_GIVEREF(__pyx_kp_u_value_2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u_value_2); __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_verb); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_passed_Labels_for_renaming_valu); __pyx_t_7 += 61; __Pyx_GIVEREF(__pyx_kp_u_passed_Labels_for_renaming_valu); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u_passed_Labels_for_renaming_valu); /* … */ __Pyx_TraceLine(4332,0,__PYX_ERR(0, 4332, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
4333: " renaming values expect to be composed of"
+4334: f" {len(values)+1} items i.e. 'number of values"
__Pyx_TraceLine(4334,0,__PYX_ERR(0, 4334, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4334, __pyx_L1_error) __pyx_t_2 = __Pyx_PyUnicode_From_Py_ssize_t((__pyx_t_9 + 1), 0, ' ', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_items_i_e_number_of_values_1_fo); __pyx_t_7 += 59; __Pyx_GIVEREF(__pyx_kp_u_items_i_e_number_of_values_1_fo); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_kp_u_items_i_e_number_of_values_1_fo);
4335: " + 1' for pure categorization.")
+4336: ur_classes = nlabels [len(labels):]
__Pyx_TraceLine(4336,0,__PYX_ERR(0, 4336, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_labels); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4336, __pyx_L1_error) __pyx_t_2 = __Pyx_PyList_GetSlice(__pyx_v_nlabels, __pyx_t_7, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4336, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_ur_classes = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+4337: labels = list(labels ) + ur_classes
__Pyx_TraceLine(4337,0,__PYX_ERR(0, 4337, __pyx_L1_error)) __pyx_t_2 = PySequence_List(__pyx_v_labels); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Add(__pyx_t_2, __pyx_v_ur_classes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4337, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_labels, __pyx_t_1); __pyx_t_1 = 0;
+4338: labels = labels [:len(nlabels)]
__Pyx_TraceLine(4338,0,__PYX_ERR(0, 4338, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyList_GET_SIZE(__pyx_v_nlabels); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4338, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_labels, 0, __pyx_t_7, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4338, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_labels, __pyx_t_1); __pyx_t_1 = 0;
+4339: msg += (f" Class{'es' if len(ur_classes)>1 else ''}"
__Pyx_TraceLine(4339,0,__PYX_ERR(0, 4339, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Class); __pyx_t_7 += 6; __Pyx_GIVEREF(__pyx_kp_u_Class); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Class); __pyx_t_9 = __Pyx_PyList_GET_SIZE(__pyx_v_ur_classes); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4339, __pyx_L1_error) __pyx_t_5 = (__pyx_t_9 > 1); if (__pyx_t_5) { __Pyx_INCREF(__pyx_n_u_es); __pyx_t_2 = __pyx_n_u_es; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_2 = __pyx_kp_u__22; } __pyx_t_3 = __Pyx_PyUnicode_Unicode(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_7 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14); /* … */ __Pyx_TraceLine(4339,0,__PYX_ERR(0, 4339, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_v_msg, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_msg, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+4340: f" {smart_format(ur_classes)} cannot be renamed." )
__Pyx_TraceLine(4340,0,__PYX_ERR(0, 4340, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_ur_classes}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4340, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_cannot_be_renamed); __pyx_t_7 += 19; __Pyx_GIVEREF(__pyx_kp_u_cannot_be_renamed); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_cannot_be_renamed);
4341:
+4342: if raise_warn:
__Pyx_TraceLine(4342,0,__PYX_ERR(0, 4342, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_raise_warn); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4342, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+4343: warnings.warn (msg )
__Pyx_TraceLine(4343,0,__PYX_ERR(0, 4343, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_msg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4343, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4344:
+4345: d = dict (zip (nlabels , labels ))
__Pyx_TraceLine(4345,0,__PYX_ERR(0, 4345, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_nlabels); __Pyx_GIVEREF(__pyx_v_nlabels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_nlabels)) __PYX_ERR(0, 4345, __pyx_L1_error); __Pyx_INCREF(__pyx_v_labels); __Pyx_GIVEREF(__pyx_v_labels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_labels)) __PYX_ERR(0, 4345, __pyx_L1_error); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyDict_Type)), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0;
4346:
+4347: return labels, d
__Pyx_TraceLine(4347,0,__PYX_ERR(0, 4347, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_labels); __Pyx_GIVEREF(__pyx_v_labels); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_labels)) __PYX_ERR(0, 4347, __pyx_L1_error); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_d)) __PYX_ERR(0, 4347, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
4348:
+4349: def _smart_mapper (k, kr , return_dict_map =False ) :
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_154_smart_mapper(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_153_smart_mapper, " Default mapping using dict to validate the continue value 'k' \n :param k: float, \n continue value to be framed between `kr`\n :param kr: Tuple, \n range of fixed values to categorize \n :return: int - new categorical class \n \n :Example: \n >>> from gofast.tools.coreutils import _smart_mapper \n >>> _smart_mapper (10000 , ( 500, 1500, 2000, 3500) )\n Out[158]: 4\n >>> _smart_mapper (10000 , ( 500, 1500, 2000, 3500) , return_dict_map=True)\n Out[159]: {0: False, 1: False, 2: False, 3: False, 4: True}\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_154_smart_mapper = {"_smart_mapper", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_154_smart_mapper, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_153_smart_mapper}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_154_smart_mapper(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_k = 0; PyObject *__pyx_v_kr = 0; PyObject *__pyx_v_return_dict_map = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_smart_mapper (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_kr,&__pyx_n_s_return_dict_map,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_k)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4349, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_kr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4349, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_smart_mapper", 0, 2, 3, 1); __PYX_ERR(0, 4349, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_dict_map); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4349, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_smart_mapper") < 0)) __PYX_ERR(0, 4349, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_k = values[0]; __pyx_v_kr = values[1]; __pyx_v_return_dict_map = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_smart_mapper", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 4349, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._smart_mapper", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_153_smart_mapper(__pyx_self, __pyx_v_k, __pyx_v_kr, __pyx_v_return_dict_map); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_153_smart_mapper(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_k, PyObject *__pyx_v_kr, PyObject *__pyx_v_return_dict_map) { PyObject *__pyx_v_math = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__189) __Pyx_TraceCall("_smart_mapper", __pyx_f[0], 4349, 0, __PYX_ERR(0, 4349, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils._smart_mapper", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_math); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__458 = PyTuple_Pack(8, __pyx_n_s_k, __pyx_n_s_kr, __pyx_n_s_return_dict_map, __pyx_n_s_math, __pyx_n_s_d_3, __pyx_n_s_ii, __pyx_n_s_v, __pyx_n_s_value); if (unlikely(!__pyx_tuple__458)) __PYX_ERR(0, 4349, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__458); __Pyx_GIVEREF(__pyx_tuple__458); /* … */ __Pyx_TraceLine(4349,0,__PYX_ERR(0, 4349, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_154_smart_mapper, 0, __pyx_n_s_smart_mapper, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__189)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__384); if (PyDict_SetItem(__pyx_d, __pyx_n_s_smart_mapper, __pyx_t_5) < 0) __PYX_ERR(0, 4349, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__189 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__458, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_smart_mapper, 4349, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__189)) __PYX_ERR(0, 4349, __pyx_L1_error)
4350: """ Default mapping using dict to validate the continue value 'k'
4351: :param k: float,
4352: continue value to be framed between `kr`
4353: :param kr: Tuple,
4354: range of fixed values to categorize
4355: :return: int - new categorical class
4356:
4357: :Example:
4358: >>> from gofast.tools.coreutils import _smart_mapper
4359: >>> _smart_mapper (10000 , ( 500, 1500, 2000, 3500) )
4360: Out[158]: 4
4361: >>> _smart_mapper (10000 , ( 500, 1500, 2000, 3500) , return_dict_map=True)
4362: Out[159]: {0: False, 1: False, 2: False, 3: False, 4: True}
4363:
4364: """
+4365: import math
__Pyx_TraceLine(4365,0,__PYX_ERR(0, 4365, __pyx_L1_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_math, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4365, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_math = __pyx_t_1; __pyx_t_1 = 0;
+4366: if len(kr )==1 :
__Pyx_TraceLine(4366,0,__PYX_ERR(0, 4366, __pyx_L1_error)) __pyx_t_2 = PyObject_Length(__pyx_v_kr); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4366, __pyx_L1_error) __pyx_t_3 = (__pyx_t_2 == 1); if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+4367: d = {0: k <=kr[0], 1: k > kr[0]}
__Pyx_TraceLine(4367,0,__PYX_ERR(0, 4367, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_kr, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_RichCompare(__pyx_v_k, __pyx_t_4, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, __pyx_t_5) < 0) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_kr, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 4367, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_d = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4368: elif len(kr)==2:
__Pyx_TraceLine(4368,0,__PYX_ERR(0, 4368, __pyx_L1_error)) __pyx_t_2 = PyObject_Length(__pyx_v_kr); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4368, __pyx_L1_error) __pyx_t_3 = (__pyx_t_2 == 2); if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+4369: d = {0: k <=kr[0], 1: kr[0] < k <= kr[1], 2: k > kr[1]}
__Pyx_TraceLine(4369,0,__PYX_ERR(0, 4369, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_kr, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_RichCompare(__pyx_v_k, __pyx_t_4, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_int_0, __pyx_t_5) < 0) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_kr, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_v_k, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4369, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_4)) { __Pyx_DECREF(__pyx_t_4); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_kr, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_6, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_int_1, __pyx_t_4) < 0) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_kr, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_RichCompare(__pyx_v_k, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_int_2, __pyx_t_5) < 0) __PYX_ERR(0, 4369, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_d = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
4370: else :
+4371: d= dict()
__Pyx_TraceLine(4371,0,__PYX_ERR(0, 4371, __pyx_L1_error)) /*else*/ { __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_d = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4372: for ii in range (len(kr) + 1 ):
__Pyx_TraceLine(4372,0,__PYX_ERR(0, 4372, __pyx_L1_error)) __pyx_t_2 = PyObject_Length(__pyx_v_kr); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4372, __pyx_L1_error) __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_2 + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_1 = __pyx_t_5; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_7 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4372, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4372, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 4372, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4372, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 4372, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4372, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4372, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(4372,0,__PYX_ERR(0, 4372, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_L3:;
+4373: if ii ==0:
__Pyx_TraceLine(4373,0,__PYX_ERR(0, 4373, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_ii, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4373, __pyx_L1_error) if (__pyx_t_3) { /* … */ goto __pyx_L6; }
+4374: d[ii]= k <= kr[ii]
__Pyx_TraceLine(4374,0,__PYX_ERR(0, 4374, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_kr, __pyx_v_ii); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4374, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4374, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely((PyDict_SetItem(__pyx_v_d, __pyx_v_ii, __pyx_t_4) < 0))) __PYX_ERR(0, 4374, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+4375: elif ii == len(kr):
__Pyx_TraceLine(4375,0,__PYX_ERR(0, 4375, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_kr); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4375, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyObject_RichCompare(__pyx_v_ii, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4375, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4375, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L6; }
+4376: d[ii] = k > kr [-1]
__Pyx_TraceLine(4376,0,__PYX_ERR(0, 4376, __pyx_L1_error)) __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_kr, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4376, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely((PyDict_SetItem(__pyx_v_d, __pyx_v_ii, __pyx_t_4) < 0))) __PYX_ERR(0, 4376, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4377: else :
+4378: d[ii] = kr[ii-1] < k <= kr[ii]
__Pyx_TraceLine(4378,0,__PYX_ERR(0, 4378, __pyx_L1_error)) /*else*/ { __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_kr, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_v_k, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4378, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_4)) { __Pyx_DECREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_kr, __pyx_v_ii); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = PyObject_RichCompare(__pyx_v_k, __pyx_t_6, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4378, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely((PyDict_SetItem(__pyx_v_d, __pyx_v_ii, __pyx_t_4) < 0))) __PYX_ERR(0, 4378, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_L6:;
4379:
+4380: if return_dict_map:
__Pyx_TraceLine(4380,0,__PYX_ERR(0, 4380, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_return_dict_map); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4380, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+4381: return d
__Pyx_TraceLine(4381,0,__PYX_ERR(0, 4381, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_d); __pyx_r = __pyx_v_d; goto __pyx_L0;
4382:
+4383: for v, value in d.items () :
__Pyx_TraceLine(4383,0,__PYX_ERR(0, 4383, __pyx_L1_error)) __pyx_t_2 = 0; __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_d, 1, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; while (1) { __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_8, &__pyx_t_2, &__pyx_t_4, &__pyx_t_5, NULL, __pyx_t_9); if (unlikely(__pyx_t_10 == 0)) break; if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 4383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5); __pyx_t_5 = 0;
+4384: if value: return v if not math.isnan (v) else np.nan
__Pyx_TraceLine(4384,0,__PYX_ERR(0, 4384, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4384, __pyx_L1_error) if (__pyx_t_3) { __Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_math, __pyx_n_s_isnan); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_v_v}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_10, 1+__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4384, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = (!__pyx_t_3); if (__pyx_t_12) { __Pyx_INCREF(__pyx_v_v); __pyx_t_5 = __pyx_v_v; } else { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4384, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4385:
+4386: def hex_to_rgb (c):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_156hex_to_rgb(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_155hex_to_rgb, " Convert colors Hexadecimal to RGB "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_156hex_to_rgb = {"hex_to_rgb", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_156hex_to_rgb, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_155hex_to_rgb}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_156hex_to_rgb(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_c = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("hex_to_rgb (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_c_2,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_c_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4386, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "hex_to_rgb") < 0)) __PYX_ERR(0, 4386, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_c = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("hex_to_rgb", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4386, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.hex_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_155hex_to_rgb(__pyx_self, __pyx_v_c); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_10hex_to_rgb_2generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_155hex_to_rgb(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_c) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb *__pyx_cur_scope; PyObject *__pyx_gb_6gofast_5tools_9coreutils_10hex_to_rgb_2generator6 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__191) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 4386, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("hex_to_rgb", __pyx_f[0], 4386, 0, __PYX_ERR(0, 4386, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_c = __pyx_v_c; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_c); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_c); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.hex_to_rgb", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_10hex_to_rgb_2generator6); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__459 = PyTuple_Pack(3, __pyx_n_s_c_2, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__459)) __PYX_ERR(0, 4386, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__459); __Pyx_GIVEREF(__pyx_tuple__459); /* … */ __Pyx_TraceLine(4386,0,__PYX_ERR(0, 4386, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_156hex_to_rgb, 0, __pyx_n_s_hex_to_rgb, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__191)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_hex_to_rgb, __pyx_t_5) < 0) __PYX_ERR(0, 4386, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__191 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__459, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_hex_to_rgb, 4386, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__191)) __PYX_ERR(0, 4386, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb { PyObject_HEAD PyObject *__pyx_v_c; };
4387: """ Convert colors Hexadecimal to RGB """
+4388: c=c.lstrip('#')
__Pyx_TraceLine(4388,0,__PYX_ERR(0, 4388, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_c, __pyx_n_s_lstrip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_kp_u__192}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_c); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_c, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
+4389: return tuple(int(c[i:i+2], 16) for i in (0, 2, 4))
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_10hex_to_rgb_genexpr(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_15_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_15_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_15_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_15_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_15_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 4389, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb *) __pyx_self;
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_10hex_to_rgb_2generator6, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_hex_to_rgb_locals_genexpr, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.hex_to_rgb.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_10hex_to_rgb_2generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4389, __pyx_L1_error)
__pyx_t_1 = __pyx_tuple__190; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
for (;;) {
if (__pyx_t_2 >= 3) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 4389, __pyx_L1_error)
#else
__pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_c)) { __Pyx_RaiseClosureNameError("c"); __PYX_ERR(0, 4389, __pyx_L1_error) }
__pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_cur_scope->__pyx_v_i, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_c, 0, 0, &__pyx_cur_scope->__pyx_v_i, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_4);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4)) __PYX_ERR(0, 4389, __pyx_L1_error);
__Pyx_INCREF(__pyx_int_16);
__Pyx_GIVEREF(__pyx_int_16);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_16)) __PYX_ERR(0, 4389, __pyx_L1_error);
__pyx_t_4 = 0;
__pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)(&PyInt_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
__Pyx_XGIVEREF(__pyx_t_1);
__pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
__pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
/* return from generator, yielding value */
__pyx_generator->resume_label = 1;
return __pyx_r;
__pyx_L6_resume_from_yield:;
__pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
__pyx_cur_scope->__pyx_t_0 = 0;
__Pyx_XGOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4389, __pyx_L1_error)
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(4389,0,__PYX_ERR(0, 4389, __pyx_L1_error))
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_10hex_to_rgb_genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* … */
__pyx_tuple__190 = PyTuple_Pack(3, __pyx_int_0, __pyx_int_2, __pyx_int_4); if (unlikely(!__pyx_tuple__190)) __PYX_ERR(0, 4389, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__190);
__Pyx_GIVEREF(__pyx_tuple__190);
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_15_genexpr {
PyObject_HEAD
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_14_hex_to_rgb *__pyx_outer_scope;
PyObject *__pyx_v_i;
PyObject *__pyx_t_0;
Py_ssize_t __pyx_t_1;
};
4390:
+4391: def zip_extractor(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_158zip_extractor(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_157zip_extractor, " Extract ZIP archive objects. \n \n Can extract all or a sample objects when the number of object is passed \n to the parameter ``samples``. \n \n .. versionadded:: 0.1.5\n \n Parameters \n -----------\n zip_file: str\n Full Path to archive Zip file. \n samples: int, str, default ='*'\n Number of data to retrieve from archive files. This is useful when \n the archive file contains many data. ``*`` means extract all. \n savepath: str, optional \n Path to store the decompressed archived files.\n ftype: str, \n<<<<<<< HEAD\n Is the extension of a specific file to decompress. Indeed, if the \n=======\n Is the extension of a the specific file to decompress. Indeed, if the \n>>>>>>> 10707dcecd7d0da55b83bcf73ae48c1e6659f2f8\n archived files contains many different data formats, specifying the \n data type would retrieve this specific files from the whole \n files archieved. \n pwd: int, optional\n Password to pass if the zip file is encrypted.\n \n Return \n --------\n objnames: list, \n List of decompressed objects. \n \n Examples \n ----------\n >>> from gofast.tools.coreutils import zip_extractor \n >>> zip_extractor ('gofast/datasets/data/edis/e.E.zip')\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_158zip_extractor = {"zip_extractor", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_158zip_extractor, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_157zip_extractor}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_158zip_extractor(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_zip_file = 0; PyObject *__pyx_v_samples = 0; PyObject *__pyx_v_ftype = 0; PyObject *__pyx_v_savepath = 0; PyObject *__pyx_v_pwd = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("zip_extractor (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_zip_file,&__pyx_n_s_samples,&__pyx_n_s_ftype,&__pyx_n_s_savepath,&__pyx_n_s_pwd,0}; PyObject* values[5] = {0,0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__36))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_157zip_extractor(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_zip_file, PyObject *__pyx_v_samples, PyObject *__pyx_v_ftype, PyObject *__pyx_v_savepath, PyObject *__pyx_v_pwd) { PyObject *__pyx_v_raise_msg_when = 0; PyObject *__pyx_v_zip_obj = NULL; PyObject *__pyx_v_objnames = NULL; PyObject *__pyx_v_zf = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__193) __Pyx_TraceCall("zip_extractor", __pyx_f[0], 4391, 0, __PYX_ERR(0, 4391, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_samples); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils.zip_extractor", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_raise_msg_when); __Pyx_XDECREF(__pyx_v_zip_obj); __Pyx_XDECREF(__pyx_v_objnames); __Pyx_XDECREF(__pyx_v_zf); __Pyx_XDECREF(__pyx_v_samples); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__460 = PyTuple_Pack(10, __pyx_n_s_zip_file, __pyx_n_s_samples, __pyx_n_s_ftype, __pyx_n_s_savepath, __pyx_n_s_pwd, __pyx_n_s_raise_msg_when, __pyx_n_s_raise_msg_when, __pyx_n_s_zip_obj, __pyx_n_s_objnames, __pyx_n_s_zf); if (unlikely(!__pyx_tuple__460)) __PYX_ERR(0, 4391, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__460); __Pyx_GIVEREF(__pyx_tuple__460); __pyx_codeobj__193 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__460, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_zip_extractor, 4391, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__193)) __PYX_ERR(0, 4391, __pyx_L1_error) /* … */ __Pyx_TraceLine(4391,0,__PYX_ERR(0, 4391, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_158zip_extractor, 0, __pyx_n_s_zip_extractor, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__193)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__461); if (PyDict_SetItem(__pyx_d, __pyx_n_s_zip_extractor, __pyx_t_5) < 0) __PYX_ERR(0, 4391, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__461 = PyTuple_Pack(4, ((PyObject*)__pyx_kp_u__36), Py_None, Py_None, Py_None); if (unlikely(!__pyx_tuple__461)) __PYX_ERR(0, 4391, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__461); __Pyx_GIVEREF(__pyx_tuple__461);
4392: zip_file ,
4393: samples ='*',
+4394: ftype=None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4395: savepath = None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4396: pwd=None,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_zip_file)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4391, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_samples); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4391, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ftype); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4391, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_savepath); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4391, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pwd); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4391, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "zip_extractor") < 0)) __PYX_ERR(0, 4391, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_zip_file = values[0]; __pyx_v_samples = values[1]; __pyx_v_ftype = values[2]; __pyx_v_savepath = values[3]; __pyx_v_pwd = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("zip_extractor", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 4391, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.zip_extractor", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_157zip_extractor(__pyx_self, __pyx_v_zip_file, __pyx_v_samples, __pyx_v_ftype, __pyx_v_savepath, __pyx_v_pwd);
4397: ):
4398: """ Extract ZIP archive objects.
4399:
4400: Can extract all or a sample objects when the number of object is passed
4401: to the parameter ``samples``.
4402:
4403: .. versionadded:: 0.1.5
4404:
4405: Parameters
4406: -----------
4407: zip_file: str
4408: Full Path to archive Zip file.
4409: samples: int, str, default ='*'
4410: Number of data to retrieve from archive files. This is useful when
4411: the archive file contains many data. ``*`` means extract all.
4412: savepath: str, optional
4413: Path to store the decompressed archived files.
4414: ftype: str,
4415: <<<<<<< HEAD
4416: Is the extension of a specific file to decompress. Indeed, if the
4417: =======
4418: Is the extension of a the specific file to decompress. Indeed, if the
4419: >>>>>>> 10707dcecd7d0da55b83bcf73ae48c1e6659f2f8
4420: archived files contains many different data formats, specifying the
4421: data type would retrieve this specific files from the whole
4422: files archieved.
4423: pwd: int, optional
4424: Password to pass if the zip file is encrypted.
4425:
4426: Return
4427: --------
4428: objnames: list,
4429: List of decompressed objects.
4430:
4431: Examples
4432: ----------
4433: >>> from gofast.tools.coreutils import zip_extractor
4434: >>> zip_extractor ('gofast/datasets/data/edis/e.E.zip')
4435:
4436: """
+4437: def raise_msg_when ( objn, ft):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13zip_extractor_1raise_msg_when(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_13zip_extractor_raise_msg_when, " Raise message when None file is detected when the type of \n of file is supplied. Otherwise return the object collected \n from this kind of data-types\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_13zip_extractor_1raise_msg_when = {"raise_msg_when", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_13zip_extractor_1raise_msg_when, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_13zip_extractor_raise_msg_when}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13zip_extractor_1raise_msg_when(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_objn = 0; PyObject *__pyx_v_ft = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("raise_msg_when (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_objn,&__pyx_n_s_ft,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_objn)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4437, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ft)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4437, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("raise_msg_when", 1, 2, 2, 1); __PYX_ERR(0, 4437, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "raise_msg_when") < 0)) __PYX_ERR(0, 4437, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_objn = values[0]; __pyx_v_ft = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("raise_msg_when", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 4437, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.zip_extractor.raise_msg_when", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_13zip_extractor_raise_msg_when(__pyx_self, __pyx_v_objn, __pyx_v_ft); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_13zip_extractor_raise_msg_when(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_objn, PyObject *__pyx_v_ft) { PyObject *__pyx_v_get_extension = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_9genexpr37__pyx_v_o = NULL; PyObject *__pyx_9genexpr38__pyx_v_s = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("raise_msg_when", __pyx_f[0], 4437, 0, __PYX_ERR(0, 4437, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_objn); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.zip_extractor.raise_msg_when", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_get_extension); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_9genexpr37__pyx_v_o); __Pyx_XDECREF(__pyx_9genexpr38__pyx_v_s); __Pyx_XDECREF(__pyx_v_objn); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__194 = PyTuple_Pack(6, __pyx_n_s_objn, __pyx_n_s_ft, __pyx_n_s_get_extension, __pyx_n_s_msg, __pyx_n_s_o, __pyx_n_s_s_2); if (unlikely(!__pyx_tuple__194)) __PYX_ERR(0, 4437, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__194); __Pyx_GIVEREF(__pyx_tuple__194); /* … */ __Pyx_TraceLine(4437,0,__PYX_ERR(0, 4437, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_13zip_extractor_1raise_msg_when, 0, __pyx_n_s_zip_extractor_locals_raise_msg_w, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__195)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4437, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_raise_msg_when = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__195 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__194, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_raise_msg_when, 4437, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__195)) __PYX_ERR(0, 4437, __pyx_L1_error)
4438: """ Raise message when None file is detected when the type of
4439: of file is supplied. Otherwise return the object collected
4440: from this kind of data-types
4441: """
+4442: objn = [ o for o in objn if o.endswith (ft)]
__Pyx_TraceLine(4442,0,__PYX_ERR(0, 4442, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_objn)) || PyTuple_CheckExact(__pyx_v_objn)) { __pyx_t_2 = __pyx_v_objn; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_objn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4442, __pyx_L5_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4442, __pyx_L5_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 4442, __pyx_L5_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4442, __pyx_L5_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 4442, __pyx_L5_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4442, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr37__pyx_v_o, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr37__pyx_v_o, __pyx_n_s_endswith); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_ft}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4442, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_9genexpr37__pyx_v_o))) __PYX_ERR(0, 4442, __pyx_L5_error) } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr37__pyx_v_o); __pyx_9genexpr37__pyx_v_o = 0; goto __pyx_L10_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_9genexpr37__pyx_v_o); __pyx_9genexpr37__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_objn, __pyx_t_1); __pyx_t_1 = 0;
+4443: if len(objn) ==0:
__Pyx_TraceLine(4443,0,__PYX_ERR(0, 4443, __pyx_L1_error)) __pyx_t_3 = PyObject_Length(__pyx_v_objn); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4443, __pyx_L1_error) __pyx_t_9 = (__pyx_t_3 == 0); if (__pyx_t_9) { /* … */ }
+4444: get_extension = [s.split('.')[-1] for s in objn if '.' in s ]
__Pyx_TraceLine(4444,0,__PYX_ERR(0, 4444, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_objn)) || PyTuple_CheckExact(__pyx_v_objn)) { __pyx_t_2 = __pyx_v_objn; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_objn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4444, __pyx_L14_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4444, __pyx_L14_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 4444, __pyx_L14_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4444, __pyx_L14_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 4444, __pyx_L14_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4444, __pyx_L14_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr38__pyx_v_s, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__26, __pyx_9genexpr38__pyx_v_s, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4444, __pyx_L14_error) if (__pyx_t_9) { __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr38__pyx_v_s, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_kp_u__26}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 4444, __pyx_L14_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr38__pyx_v_s); __pyx_9genexpr38__pyx_v_s = 0; goto __pyx_L19_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_9genexpr38__pyx_v_s); __pyx_9genexpr38__pyx_v_s = 0; goto __pyx_L1_error; __pyx_L19_exit_scope:; } /* exit inner scope */ __pyx_v_get_extension = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+4445: if len(get_extension)==0 : get_extension=['']
__Pyx_TraceLine(4445,0,__PYX_ERR(0, 4445, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyList_GET_SIZE(__pyx_v_get_extension); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4445, __pyx_L1_error) __pyx_t_9 = (__pyx_t_3 == 0); if (__pyx_t_9) { __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_u__22); __Pyx_GIVEREF(__pyx_kp_u__22); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__22)) __PYX_ERR(0, 4445, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_get_extension, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0; }
4446: msg = ( "The available file types are {smart_format(get_extension)}"
+4447: if len(get_extension)!=0 else ''
__Pyx_TraceLine(4447,0,__PYX_ERR(0, 4447, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyList_GET_SIZE(__pyx_v_get_extension); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4447, __pyx_L1_error) __pyx_t_9 = (__pyx_t_3 != 0); if (__pyx_t_9) { __Pyx_INCREF(__pyx_kp_u_The_available_file_types_are_sma); __pyx_t_1 = __pyx_kp_u_The_available_file_types_are_sma; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_1 = __pyx_kp_u__22; } __pyx_v_msg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
4448: )
+4449: raise ValueError (f"None objects in the zip collection of matches"
__Pyx_TraceLine(4449,0,__PYX_ERR(0, 4449, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_None_objects_in_the_zip_collecti); __pyx_t_3 += 49; __Pyx_GIVEREF(__pyx_kp_u_None_objects_in_the_zip_collecti); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_None_objects_in_the_zip_collecti); /* … */ __Pyx_TraceLine(4449,0,__PYX_ERR(0, 4449, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4449, __pyx_L1_error)
+4450: f"the {ft!r}. Available file types are {msg}")
__Pyx_TraceLine(4450,0,__PYX_ERR(0, 4450, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_ft), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_10; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_Available_file_types_are); __pyx_t_3 += 27; __Pyx_GIVEREF(__pyx_kp_u_Available_file_types_are); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Available_file_types_are); __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_v_msg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4450, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_10; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_2); __pyx_t_2 = 0;
+4451: return objn
__Pyx_TraceLine(4451,0,__PYX_ERR(0, 4451, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_objn); __pyx_r = __pyx_v_objn; goto __pyx_L0;
4452:
+4453: if not os.path.isfile (zip_file ):
__Pyx_TraceLine(4453,0,__PYX_ERR(0, 4453, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isfile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_zip_file}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4453, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (!__pyx_t_5); if (unlikely(__pyx_t_6)) { /* … */ }
+4454: raise FileExistsError( f"File {os.path.basename(zip_file)!r} does"
__Pyx_TraceLine(4454,0,__PYX_ERR(0, 4454, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_FileExistsError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_File_2); __pyx_t_7 += 5; __Pyx_GIVEREF(__pyx_kp_u_File_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_File_2); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_basename); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_zip_file}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_3), __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_does_not_exist_Expect_a_Path_li); __pyx_t_7 += 48; __Pyx_GIVEREF(__pyx_kp_u_does_not_exist_Expect_a_Path_li); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_does_not_exist_Expect_a_Path_li); /* … */ __Pyx_TraceLine(4454,0,__PYX_ERR(0, 4454, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_2, 4, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 4454, __pyx_L1_error)
4455: " not exist. Expect a Path-like object,"
+4456: f" got {type(zip_file).__name__!r}")
__Pyx_TraceLine(4456,0,__PYX_ERR(0, 4456, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_zip_file)), __pyx_n_s_name); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_9), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_3); __pyx_t_3 = 0;
4457:
+4458: if not os.path.basename(zip_file ).lower().endswith ('.zip'):
__Pyx_TraceLine(4458,0,__PYX_ERR(0, 4458, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_basename); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_zip_file}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lower); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_endswith); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_kp_u_zip_2}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4458, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (!__pyx_t_6); if (unlikely(__pyx_t_5)) { /* … */ }
+4459: raise FileNotFoundError("Unrecognized zip-file.")
__Pyx_TraceLine(4459,0,__PYX_ERR(0, 4459, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__196, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 4459, __pyx_L1_error) /* … */ __pyx_tuple__196 = PyTuple_Pack(1, __pyx_kp_u_Unrecognized_zip_file); if (unlikely(!__pyx_tuple__196)) __PYX_ERR(0, 4459, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__196); __Pyx_GIVEREF(__pyx_tuple__196);
4460:
+4461: samples = str(samples)
__Pyx_TraceLine(4461,0,__PYX_ERR(0, 4461, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_Str(__pyx_v_samples); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_samples, __pyx_t_9); __pyx_t_9 = 0;
+4462: if samples !='*':
__Pyx_TraceLine(4462,0,__PYX_ERR(0, 4462, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_samples, __pyx_kp_u__36, Py_NE)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4462, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+4463: try :samples = int (samples )
__Pyx_TraceLine(4463,0,__PYX_ERR(0, 4463, __pyx_L1_error)) { /*try:*/ { __pyx_t_9 = __Pyx_PyNumber_Int(__pyx_v_samples); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4463, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_samples, __pyx_t_9); __pyx_t_9 = 0; } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L11_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13); goto __pyx_L1_error; __pyx_L11_try_end:; }
+4464: except:
__Pyx_TraceLine(4464,0,__PYX_ERR(0, 4464, __pyx_L8_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.zip_extractor", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 4464, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3);
+4465: raise ValueError ("samples must be an integer value"
__Pyx_TraceLine(4465,0,__PYX_ERR(0, 4465, __pyx_L8_except_error)) __pyx_t_10 = __Pyx_PyUnicode_Concat(__pyx_kp_u_samples_must_be_an_integer_value, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4465, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4465, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 4465, __pyx_L8_except_error) }
+4466: f" or '*' not {samples}")
__Pyx_TraceLine(4466,0,__PYX_ERR(0, 4466, __pyx_L8_except_error)) __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_samples, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4466, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_1);
4467:
+4468: with ZipFile (zip_file, 'r', ) as zip_obj :
__Pyx_TraceLine(4468,0,__PYX_ERR(0, 4468, __pyx_L1_error)) /*with:*/ { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ZipFile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_v_zip_file, __pyx_n_u_r}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4468, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4468, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __pyx_v_zip_obj = __pyx_t_9; __pyx_t_9 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; goto __pyx_L23_try_end; __pyx_L18_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.zip_extractor", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_10, &__pyx_t_1) < 0) __PYX_ERR(0, 4468, __pyx_L20_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_1); __pyx_t_9 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4468, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_9, NULL); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4468, __pyx_L20_except_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_16); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__pyx_t_5 < 0) __PYX_ERR(0, 4468, __pyx_L20_except_error) __pyx_t_6 = (!__pyx_t_5); if (unlikely(__pyx_t_6)) { __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_1); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_10, __pyx_t_1); __pyx_t_3 = 0; __pyx_t_10 = 0; __pyx_t_1 = 0; __PYX_ERR(0, 4468, __pyx_L20_except_error) } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L19_exception_handled; } __pyx_L20_except_error:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_14); goto __pyx_L1_error; __pyx_L19_exception_handled:; __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_14); __pyx_L23_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_13) { __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } goto __pyx_L17; } __pyx_L17:; } goto __pyx_L35; __pyx_L14_error:; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L1_error; __pyx_L35:; }
+4469: objnames = zip_obj.namelist()
__Pyx_TraceLine(4469,0,__PYX_ERR(0, 4469, __pyx_L18_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_zip_obj, __pyx_n_s_namelist); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4469, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4469, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_objnames = __pyx_t_9; __pyx_t_9 = 0;
+4470: if samples =='*':
__Pyx_TraceLine(4470,0,__PYX_ERR(0, 4470, __pyx_L18_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_samples, __pyx_kp_u__36, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4470, __pyx_L18_error) if (__pyx_t_5) { /* … */ }
+4471: samples = len(objnames )
__Pyx_TraceLine(4471,0,__PYX_ERR(0, 4471, __pyx_L18_error)) __pyx_t_7 = PyObject_Length(__pyx_v_objnames); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4471, __pyx_L18_error) __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4471, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF_SET(__pyx_v_samples, __pyx_t_9); __pyx_t_9 = 0;
4472:
+4473: if ftype is not None:
__Pyx_TraceLine(4473,0,__PYX_ERR(0, 4473, __pyx_L18_error)) __pyx_t_5 = (__pyx_v_ftype != Py_None); if (__pyx_t_5) { /* … */ }
+4474: objnames = raise_msg_when(objn=objnames, ft= ftype)
__Pyx_TraceLine(4474,0,__PYX_ERR(0, 4474, __pyx_L18_error)) __pyx_t_9 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4474, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_objn, __pyx_v_objnames) < 0) __PYX_ERR(0, 4474, __pyx_L18_error) if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_ft, __pyx_v_ftype) < 0) __PYX_ERR(0, 4474, __pyx_L18_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_raise_msg_when, __pyx_empty_tuple, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4474, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF_SET(__pyx_v_objnames, __pyx_t_3); __pyx_t_3 = 0;
4475:
+4476: if ( samples >= len(objnames)
__Pyx_TraceLine(4476,0,__PYX_ERR(0, 4476, __pyx_L18_error)) __pyx_t_7 = PyObject_Length(__pyx_v_objnames); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4476, __pyx_L18_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4476, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyObject_RichCompare(__pyx_v_samples, __pyx_t_3, Py_GE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4476, __pyx_L18_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4476, __pyx_L18_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L27_bool_binop_done; } /* … */ __Pyx_TraceLine(4476,0,__PYX_ERR(0, 4476, __pyx_L18_error)) if (__pyx_t_5) { /* … */ goto __pyx_L26; }
+4477: and ftype is None
__Pyx_TraceLine(4477,0,__PYX_ERR(0, 4477, __pyx_L18_error)) __pyx_t_6 = (__pyx_v_ftype == Py_None); __pyx_t_5 = __pyx_t_6; __pyx_L27_bool_binop_done:;
4478: ) :
+4479: zip_obj.extractall( path = savepath , pwd=pwd)
__Pyx_TraceLine(4479,0,__PYX_ERR(0, 4479, __pyx_L18_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_zip_obj, __pyx_n_s_extractall); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4479, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4479, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_path, __pyx_v_savepath) < 0) __PYX_ERR(0, 4479, __pyx_L18_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pwd, __pyx_v_pwd) < 0) __PYX_ERR(0, 4479, __pyx_L18_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4479, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4480: else:
+4481: for zf in objnames [:samples ]:
__Pyx_TraceLine(4481,0,__PYX_ERR(0, 4481, __pyx_L18_error)) /*else*/ { __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_objnames, 0, 0, NULL, &__pyx_v_samples, NULL, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4481, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; __pyx_t_15 = NULL; } else { __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4481, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4481, __pyx_L18_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4481, __pyx_L18_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 4481, __pyx_L18_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4481, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4481, __pyx_L18_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 4481, __pyx_L18_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4481, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_15(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4481, __pyx_L18_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_zf, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(4481,0,__PYX_ERR(0, 4481, __pyx_L18_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L26:;
+4482: zip_obj.extract ( zf, path = savepath, pwd = pwd)
__Pyx_TraceLine(4482,0,__PYX_ERR(0, 4482, __pyx_L18_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_zip_obj, __pyx_n_s_extract); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4482, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4482, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_zf); __Pyx_GIVEREF(__pyx_v_zf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_zf)) __PYX_ERR(0, 4482, __pyx_L18_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4482, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_path, __pyx_v_savepath) < 0) __PYX_ERR(0, 4482, __pyx_L18_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_pwd, __pyx_v_pwd) < 0) __PYX_ERR(0, 4482, __pyx_L18_error) __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4482, __pyx_L18_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
4483:
+4484: return objnames
__Pyx_TraceLine(4484,0,__PYX_ERR(0, 4484, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_objnames)) { __Pyx_RaiseUnboundLocalError("objnames"); __PYX_ERR(0, 4484, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_objnames); __pyx_r = __pyx_v_objnames; goto __pyx_L0;
4485:
4486:
+4487: def _validate_name_in (name, defaults = '', expect_name= None,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_160_validate_name_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_159_validate_name_in, " Assert name in multiples given default names. \n \n Parameters \n -----------\n name: str, \n given name to assert \n default: list, str, default =''\n default values used for assertion \n expect_name: str, optional \n name to return in case assertion is verified ( as ``True``)\n deep: bool, default=False \n Find item in a litteral default string. If set to ``True``, \n `defaults` are joined and check whether an occurence of `name` is in the \n defaults \n \n exception: Exception \n Error to raise if name is not found in the default values. \n \n Returns\n -------\n name: str, \n Verified name or boolean if expect name if ``None``. \n \n Examples \n -------\n >>> from gofast.tools.coreutils import _validate_name_in \n >>> dnames = ('NAME', 'FIST NAME', 'SUrname')\n >>> _validate_name_in ('name', defaults=dnames )\n False \n >>> _validate_name_in ('name', defaults= dnames, deep =True )\n True\n >>> _validate_name_in ('name', defaults=dnames , expect_name ='NAM')\n False \n >>> _validate_name_in ('name', defaults=dnames , expect_name ='NAM', deep=True)\n 'NAM'\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_160_validate_name_in = {"_validate_name_in", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_160_validate_name_in, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_159_validate_name_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_160_validate_name_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_name = 0; PyObject *__pyx_v_defaults = 0; PyObject *__pyx_v_expect_name = 0; PyObject *__pyx_v_exception = 0; PyObject *__pyx_v_deep = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_validate_name_in (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name_2,&__pyx_n_s_defaults,&__pyx_n_s_expect_name,&__pyx_n_s_exception,&__pyx_n_s_deep,0}; PyObject* values[5] = {0,0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u__22))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_159_validate_name_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_defaults, PyObject *__pyx_v_expect_name, PyObject *__pyx_v_exception, PyObject *__pyx_v_deep) { PyObject *__pyx_9genexpr39__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__197) __Pyx_TraceCall("_validate_name_in", __pyx_f[0], 4487, 0, __PYX_ERR(0, 4487, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_name); __Pyx_INCREF(__pyx_v_defaults); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils._validate_name_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_9genexpr39__pyx_v_i); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_defaults); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__462 = PyTuple_Pack(6, __pyx_n_s_name_2, __pyx_n_s_defaults, __pyx_n_s_expect_name, __pyx_n_s_exception, __pyx_n_s_deep, __pyx_n_s_i); if (unlikely(!__pyx_tuple__462)) __PYX_ERR(0, 4487, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__462); __Pyx_GIVEREF(__pyx_tuple__462); __pyx_codeobj__197 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__462, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_name_in, 4487, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__197)) __PYX_ERR(0, 4487, __pyx_L1_error) /* … */ __Pyx_TraceLine(4487,0,__PYX_ERR(0, 4487, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_160_validate_name_in, 0, __pyx_n_s_validate_name_in, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__197)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4487, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__463); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_name_in, __pyx_t_5) < 0) __PYX_ERR(0, 4487, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__463 = PyTuple_Pack(4, ((PyObject*)__pyx_kp_u__22), Py_None, Py_None, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__463)) __PYX_ERR(0, 4487, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__463); __Pyx_GIVEREF(__pyx_tuple__463);
+4488: exception = None , deep=False ):
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4487, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_defaults); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4487, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_expect_name); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4487, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exception); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4487, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4487, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_validate_name_in") < 0)) __PYX_ERR(0, 4487, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = values[0]; __pyx_v_defaults = values[1]; __pyx_v_expect_name = values[2]; __pyx_v_exception = values[3]; __pyx_v_deep = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_validate_name_in", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 4487, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._validate_name_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_159_validate_name_in(__pyx_self, __pyx_v_name, __pyx_v_defaults, __pyx_v_expect_name, __pyx_v_exception, __pyx_v_deep);
4489: """ Assert name in multiples given default names.
4490:
4491: Parameters
4492: -----------
4493: name: str,
4494: given name to assert
4495: default: list, str, default =''
4496: default values used for assertion
4497: expect_name: str, optional
4498: name to return in case assertion is verified ( as ``True``)
4499: deep: bool, default=False
4500: Find item in a litteral default string. If set to ``True``,
4501: `defaults` are joined and check whether an occurence of `name` is in the
4502: defaults
4503:
4504: exception: Exception
4505: Error to raise if name is not found in the default values.
4506:
4507: Returns
4508: -------
4509: name: str,
4510: Verified name or boolean if expect name if ``None``.
4511:
4512: Examples
4513: -------
4514: >>> from gofast.tools.coreutils import _validate_name_in
4515: >>> dnames = ('NAME', 'FIST NAME', 'SUrname')
4516: >>> _validate_name_in ('name', defaults=dnames )
4517: False
4518: >>> _validate_name_in ('name', defaults= dnames, deep =True )
4519: True
4520: >>> _validate_name_in ('name', defaults=dnames , expect_name ='NAM')
4521: False
4522: >>> _validate_name_in ('name', defaults=dnames , expect_name ='NAM', deep=True)
4523: 'NAM'
4524: """
4525:
+4526: name = str(name).lower().strip()
__Pyx_TraceLine(4526,0,__PYX_ERR(0, 4526, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lower); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_1); __pyx_t_1 = 0;
+4527: defaults = is_iterable(defaults,
__Pyx_TraceLine(4527,0,__PYX_ERR(0, 4527, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_defaults); __Pyx_GIVEREF(__pyx_v_defaults); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_defaults)) __PYX_ERR(0, 4527, __pyx_L1_error); /* … */ __Pyx_TraceLine(4527,0,__PYX_ERR(0, 4527, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_defaults, __pyx_t_3); __pyx_t_3 = 0;
+4528: exclude_string= True, parse_string= True, transform=True )
__Pyx_TraceLine(4528,0,__PYX_ERR(0, 4528, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 4528, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parse_string, Py_True) < 0) __PYX_ERR(0, 4528, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 4528, __pyx_L1_error)
+4529: if deep :
__Pyx_TraceLine(4529,0,__PYX_ERR(0, 4529, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_deep); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4529, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+4530: defaults = ''.join([ str(i) for i in defaults] )
__Pyx_TraceLine(4530,0,__PYX_ERR(0, 4530, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4530, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_v_defaults)) || PyTuple_CheckExact(__pyx_v_defaults)) { __pyx_t_2 = __pyx_v_defaults; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_defaults); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4530, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4530, __pyx_L6_error) } for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4530, __pyx_L6_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 4530, __pyx_L6_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4530, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4530, __pyx_L6_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 4530, __pyx_L6_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4530, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_8(__pyx_t_2); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4530, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_9genexpr39__pyx_v_i, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Str(__pyx_9genexpr39__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4530, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 4530, __pyx_L6_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr39__pyx_v_i); __pyx_9genexpr39__pyx_v_i = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr39__pyx_v_i); __pyx_9genexpr39__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_defaults, __pyx_t_2); __pyx_t_2 = 0;
4531:
4532: # if name in defaults:
+4533: name = ( True if expect_name is None else expect_name
__Pyx_TraceLine(4533,0,__PYX_ERR(0, 4533, __pyx_L1_error)) __pyx_t_9 = (__pyx_v_expect_name == Py_None); if (__pyx_t_9) { __Pyx_INCREF(Py_True); __pyx_t_3 = Py_True; } else { __Pyx_INCREF(__pyx_v_expect_name); __pyx_t_3 = __pyx_v_expect_name; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else {
+4534: ) if name in defaults else False
__Pyx_TraceLine(4534,0,__PYX_ERR(0, 4534, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_v_name, __pyx_v_defaults, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4534, __pyx_L1_error) if (__pyx_t_6) { /* … */ __Pyx_TraceLine(4534,0,__PYX_ERR(0, 4534, __pyx_L1_error)) __Pyx_INCREF(Py_False); __pyx_t_2 = Py_False; } __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_2); __pyx_t_2 = 0;
4535:
4536: #name = True if name in defaults else ( expect_name if expect_name else False )
4537:
+4538: if not name and exception:
__Pyx_TraceLine(4538,0,__PYX_ERR(0, 4538, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4538, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_9); if (__pyx_t_10) { } else { __pyx_t_6 = __pyx_t_10; goto __pyx_L12_bool_binop_done; } __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_exception); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 4538, __pyx_L1_error) __pyx_t_6 = __pyx_t_10; __pyx_L12_bool_binop_done:; if (unlikely(__pyx_t_6)) { /* … */ }
+4539: raise exception
__Pyx_TraceLine(4539,0,__PYX_ERR(0, 4539, __pyx_L1_error)) __Pyx_Raise(__pyx_v_exception, 0, 0, 0); __PYX_ERR(0, 4539, __pyx_L1_error)
4540:
+4541: return name
__Pyx_TraceLine(4541,0,__PYX_ERR(0, 4541, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_name); __pyx_r = __pyx_v_name; goto __pyx_L0;
4542:
+4543: def get_confidence_ratio (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_162get_confidence_ratio(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_161get_confidence_ratio, " Get ratio of confidence in array by counting the number of \n invalid values. \n \n Parameters \n ------------\n ar: arraylike 1D or 2D \n array for checking the ratio of confidence \n \n axis: int, default=0, \n Compute the ratio of confidence alongside the rows by defaults. \n \n invalid: int, foat, default='NaN'\n The value to consider as invalid in the data might be listed if \n applicable. The default is ``NaN``. \n \n mean: bool, default=False, \n Get the mean ratio. Average the percentage of each axis. \n \n .. versionadded:: 0.2.8 \n Average the ratio of confidence of each axis. \n \n Returns \n ---------\n ratio: arraylike 1D \n The ratio of confidence array alongside the ``axis``. \n\n Examples \n ----------\n >>> import numpy as np \n >>> np.random.seed (0) \n >>> test = np.random.randint (1, 20 , 10 ).reshape (5, 2 ) \n >>> test\n array([[13, 16],\n [ 1, 4],\n [ 4, 8],\n [10, 19],\n [ 5, 7]])\n >>> from gofast.tools.coreutils import get_confidence_ratio \n >>> get_confidence_ratio (test)\n >>> array([1., 1.])\n >>> get_confidence_ratio (test, invalid= ( 13, 19) )\n array([0.8, 0.8])\n >>> get_confidence_ratio (test, invalid= ( 13, 19, 4) )\n array([0.6, 0.6])\n >>> get_confidence_ratio (test, invalid= ( 13, 19, 4), axis =1 )\n array([0.5, 0.5, 0.5, 0.5, 1. ])\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_162get_confidence_ratio = {"get_confidence_ratio", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_162get_confidence_ratio, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_161get_confidence_ratio}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_162get_confidence_ratio(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_ar = 0; PyObject *__pyx_v_axis = 0; PyObject *__pyx_v_invalid = 0; PyObject *__pyx_v_mean = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_confidence_ratio (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ar,&__pyx_n_s_axis,&__pyx_n_s_invalid,&__pyx_n_s_mean,0}; PyObject* values[4] = {0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_NaN))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_161get_confidence_ratio(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ar, PyObject *__pyx_v_axis, PyObject *__pyx_v_invalid, PyObject *__pyx_v_mean) { PyObject *__pyx_v_gfc = 0; PyObject *__pyx_v_ratio = NULL; Py_ssize_t __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__198) __Pyx_TraceCall("get_confidence_ratio", __pyx_f[0], 4543, 0, __PYX_ERR(0, 4543, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_ar); __Pyx_INCREF(__pyx_v_axis); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.get_confidence_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_gfc); __Pyx_XDECREF(__pyx_v_ratio); __Pyx_XDECREF(__pyx_v_ar); __Pyx_XDECREF(__pyx_v_axis); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__464 = PyTuple_Pack(8, __pyx_n_s_ar, __pyx_n_s_axis, __pyx_n_s_invalid, __pyx_n_s_mean, __pyx_n_s_gfc, __pyx_n_s_gfc, __pyx_n_s_ratio, __pyx_n_s_i); if (unlikely(!__pyx_tuple__464)) __PYX_ERR(0, 4543, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__464); __Pyx_GIVEREF(__pyx_tuple__464); __pyx_codeobj__198 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__464, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_confidence_ratio, 4543, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__198)) __PYX_ERR(0, 4543, __pyx_L1_error) /* … */ __Pyx_TraceLine(4543,0,__PYX_ERR(0, 4543, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_162get_confidence_ratio, 0, __pyx_n_s_get_confidence_ratio, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__198)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__465); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_confidence_ratio, __pyx_t_5) < 0) __PYX_ERR(0, 4543, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__465 = PyTuple_Pack(3, ((PyObject *)__pyx_int_0), ((PyObject*)__pyx_n_u_NaN), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__465)) __PYX_ERR(0, 4543, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__465); __Pyx_GIVEREF(__pyx_tuple__465);
4544: ar,
4545: axis = 0,
4546: invalid = 'NaN',
+4547: mean=False,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ar)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4543, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_axis); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4543, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_invalid); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4543, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_mean); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4543, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_confidence_ratio") < 0)) __PYX_ERR(0, 4543, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_ar = values[0]; __pyx_v_axis = values[1]; __pyx_v_invalid = values[2]; __pyx_v_mean = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_confidence_ratio", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 4543, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_confidence_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_161get_confidence_ratio(__pyx_self, __pyx_v_ar, __pyx_v_axis, __pyx_v_invalid, __pyx_v_mean);
4548: ):
4549:
4550: """ Get ratio of confidence in array by counting the number of
4551: invalid values.
4552:
4553: Parameters
4554: ------------
4555: ar: arraylike 1D or 2D
4556: array for checking the ratio of confidence
4557:
4558: axis: int, default=0,
4559: Compute the ratio of confidence alongside the rows by defaults.
4560:
4561: invalid: int, foat, default='NaN'
4562: The value to consider as invalid in the data might be listed if
4563: applicable. The default is ``NaN``.
4564:
4565: mean: bool, default=False,
4566: Get the mean ratio. Average the percentage of each axis.
4567:
4568: .. versionadded:: 0.2.8
4569: Average the ratio of confidence of each axis.
4570:
4571: Returns
4572: ---------
4573: ratio: arraylike 1D
4574: The ratio of confidence array alongside the ``axis``.
4575:
4576: Examples
4577: ----------
4578: >>> import numpy as np
4579: >>> np.random.seed (0)
4580: >>> test = np.random.randint (1, 20 , 10 ).reshape (5, 2 )
4581: >>> test
4582: array([[13, 16],
4583: [ 1, 4],
4584: [ 4, 8],
4585: [10, 19],
4586: [ 5, 7]])
4587: >>> from gofast.tools.coreutils import get_confidence_ratio
4588: >>> get_confidence_ratio (test)
4589: >>> array([1., 1.])
4590: >>> get_confidence_ratio (test, invalid= ( 13, 19) )
4591: array([0.8, 0.8])
4592: >>> get_confidence_ratio (test, invalid= ( 13, 19, 4) )
4593: array([0.6, 0.6])
4594: >>> get_confidence_ratio (test, invalid= ( 13, 19, 4), axis =1 )
4595: array([0.5, 0.5, 0.5, 0.5, 1. ])
4596:
4597: """
+4598: def gfc ( ar, inv):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_20get_confidence_ratio_1gfc(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_20get_confidence_ratio_gfc, " Get ratio in each column or row in the array. "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_20get_confidence_ratio_1gfc = {"gfc", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_20get_confidence_ratio_1gfc, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_20get_confidence_ratio_gfc}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_20get_confidence_ratio_1gfc(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_ar = 0; PyObject *__pyx_v_inv = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("gfc (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ar,&__pyx_n_s_inv,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ar)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4598, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_inv)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4598, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("gfc", 1, 2, 2, 1); __PYX_ERR(0, 4598, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "gfc") < 0)) __PYX_ERR(0, 4598, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_ar = values[0]; __pyx_v_inv = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("gfc", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 4598, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_confidence_ratio.gfc", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_20get_confidence_ratio_gfc(__pyx_self, __pyx_v_ar, __pyx_v_inv); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_20get_confidence_ratio_gfc(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ar, PyObject *__pyx_v_inv) { PyObject *__pyx_v_iv = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("gfc", __pyx_f[0], 4598, 0, __PYX_ERR(0, 4598, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_inv); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.get_confidence_ratio.gfc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_iv); __Pyx_XDECREF(__pyx_v_inv); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__199 = PyTuple_Pack(3, __pyx_n_s_ar, __pyx_n_s_inv, __pyx_n_s_iv); if (unlikely(!__pyx_tuple__199)) __PYX_ERR(0, 4598, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__199); __Pyx_GIVEREF(__pyx_tuple__199); /* … */ __Pyx_TraceLine(4598,0,__PYX_ERR(0, 4598, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_20get_confidence_ratio_1gfc, 0, __pyx_n_s_get_confidence_ratio_locals_gfc, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__200)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4598, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_gfc = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__200 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__199, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_gfc, 4598, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__200)) __PYX_ERR(0, 4598, __pyx_L1_error)
4599: """ Get ratio in each column or row in the array. """
+4600: inv = is_iterable(inv, exclude_string=True , transform =True,
__Pyx_TraceLine(4600,0,__PYX_ERR(0, 4600, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_inv); __Pyx_GIVEREF(__pyx_v_inv); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_inv)) __PYX_ERR(0, 4600, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 4600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 4600, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_inv, __pyx_t_4); __pyx_t_4 = 0;
4601: )
4602: # if inv!='NaN':
+4603: for iv in inv:
__Pyx_TraceLine(4603,0,__PYX_ERR(0, 4603, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_inv)) || PyTuple_CheckExact(__pyx_v_inv)) { __pyx_t_4 = __pyx_v_inv; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inv); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4603, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4603, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 4603, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4603, __pyx_L1_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 4603, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 4603, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_iv, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(4603,0,__PYX_ERR(0, 4603, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+4604: if iv in ('NAN', np.nan, 'NaN', 'nan', None):
__Pyx_TraceLine(4604,0,__PYX_ERR(0, 4604, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_iv); __pyx_t_3 = __pyx_v_iv; __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_NAN, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4604, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L6_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4604, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_1, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4604, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4604, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L6_bool_binop_done; } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_NaN, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4604, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L6_bool_binop_done; } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_n_u_nan, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4604, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L6_bool_binop_done; } __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4604, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4604, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __pyx_t_8; __pyx_L6_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __pyx_t_7; if (__pyx_t_8) { /* … */ }
+4605: iv=np.nan
__Pyx_TraceLine(4605,0,__PYX_ERR(0, 4605, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4605, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_nan); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4605, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_iv, __pyx_t_2); __pyx_t_2 = 0;
+4606: ar [ar ==iv] = np.nan
__Pyx_TraceLine(4606,0,__PYX_ERR(0, 4606, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyObject_RichCompare(__pyx_v_ar, __pyx_v_iv, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4606, __pyx_L1_error) if (unlikely((PyObject_SetItem(__pyx_v_ar, __pyx_t_2, __pyx_t_3) < 0))) __PYX_ERR(0, 4606, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4607:
+4608: return len( ar [ ~np.isnan (ar)]) / len(ar )
__Pyx_TraceLine(4608,0,__PYX_ERR(0, 4608, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isnan); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_ar}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = PyNumber_Invert(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_ar, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_10 = PyObject_Length(__pyx_v_ar); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4608, __pyx_L1_error) if (unlikely(__pyx_t_10 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "float division"); __PYX_ERR(0, 4608, __pyx_L1_error) } __pyx_t_4 = PyFloat_FromDouble((((double)__pyx_t_5) / ((double)__pyx_t_10))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
4609:
4610: # validate input axis name
+4611: axis = _validate_name_in (axis , ('1', 'rows', 'sites', 'stations') ,
__Pyx_TraceLine(4611,0,__PYX_ERR(0, 4611, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_validate_name_in); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_axis); __Pyx_GIVEREF(__pyx_v_axis); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_axis)) __PYX_ERR(0, 4611, __pyx_L1_error); __Pyx_INCREF(__pyx_tuple__201); __Pyx_GIVEREF(__pyx_tuple__201); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_tuple__201)) __PYX_ERR(0, 4611, __pyx_L1_error); /* … */ __Pyx_TraceLine(4611,0,__PYX_ERR(0, 4611, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_axis, __pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_tuple__201 = PyTuple_Pack(4, __pyx_kp_u_1, __pyx_n_u_rows, __pyx_n_u_sites, __pyx_n_u_stations); if (unlikely(!__pyx_tuple__201)) __PYX_ERR(0, 4611, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__201); __Pyx_GIVEREF(__pyx_tuple__201);
+4612: expect_name=1 )
__Pyx_TraceLine(4612,0,__PYX_ERR(0, 4612, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_expect_name, __pyx_int_1) < 0) __PYX_ERR(0, 4612, __pyx_L1_error)
+4613: if not axis:
__Pyx_TraceLine(4613,0,__PYX_ERR(0, 4613, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_axis); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4613, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ }
+4614: axis =0
__Pyx_TraceLine(4614,0,__PYX_ERR(0, 4614, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __Pyx_DECREF_SET(__pyx_v_axis, __pyx_int_0);
4615:
+4616: ar = np.array(ar).astype ( np.float64) # for consistency
__Pyx_TraceLine(4616,0,__PYX_ERR(0, 4616, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_ar}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_astype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_2}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4616, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_ar, __pyx_t_4); __pyx_t_4 = 0;
+4617: ratio = np.zeros(( (ar.shape[0] if axis ==1 else ar.shape [1] )
__Pyx_TraceLine(4617,0,__PYX_ERR(0, 4617, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(4617,0,__PYX_ERR(0, 4617, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_axis, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4617, __pyx_L1_error) if (__pyx_t_5) { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_8; __pyx_t_8 = 0; } else { __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_shape); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_t_4 = __pyx_t_2; __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_int_1); __pyx_t_4 = __pyx_int_1; } __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4)) __PYX_ERR(0, 4617, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2)) __PYX_ERR(0, 4617, __pyx_L1_error); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(4617,0,__PYX_ERR(0, 4617, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4617, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_ratio = __pyx_t_8; __pyx_t_8 = 0;
+4618: if ar.ndim ==2 else 1, ), dtype= np.float64)
__Pyx_TraceLine(4618,0,__PYX_ERR(0, 4618, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4618, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ __Pyx_TraceLine(4618,0,__PYX_ERR(0, 4618, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_float64); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_8) < 0) __PYX_ERR(0, 4618, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4619:
+4620: for i in range (len(ratio)):
__Pyx_TraceLine(4620,0,__PYX_ERR(0, 4620, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_ratio); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4620, __pyx_L1_error) __pyx_t_10 = __pyx_t_9; for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_i = __pyx_t_11;
+4621: ratio[i] = gfc ( (ar [:, i] if axis ==0 else ar [i, :])
__Pyx_TraceLine(4621,0,__PYX_ERR(0, 4621, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_axis, __pyx_int_0, 0, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4621, __pyx_L1_error) if (__pyx_t_5) { __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__130)) __PYX_ERR(0, 4621, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_ar, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_4; __pyx_t_4 = 0; } else { __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__130)) __PYX_ERR(0, 4621, __pyx_L1_error); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_ar, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_t_8 = __pyx_t_2; __pyx_t_2 = 0; } else { /* … */ __Pyx_TraceLine(4621,0,__PYX_ERR(0, 4621, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8)) __PYX_ERR(0, 4621, __pyx_L1_error); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(4621,0,__PYX_ERR(0, 4621, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_gfc, __pyx_t_2, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely((__Pyx_SetItemInt(__pyx_v_ratio, __pyx_v_i, __pyx_t_4, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1) < 0))) __PYX_ERR(0, 4621, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; }
+4622: if ar.ndim !=1 else ar , inv= invalid
__Pyx_TraceLine(4622,0,__PYX_ERR(0, 4622, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4622, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ __Pyx_TraceLine(4622,0,__PYX_ERR(0, 4622, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_ar); __pyx_t_8 = __pyx_v_ar; } /* … */ __Pyx_TraceLine(4622,0,__PYX_ERR(0, 4622, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_inv, __pyx_v_invalid) < 0) __PYX_ERR(0, 4622, __pyx_L1_error)
4623: )
+4624: if mean:
__Pyx_TraceLine(4624,0,__PYX_ERR(0, 4624, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_mean); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4624, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+4625: ratio = np.array (ratio).mean()
__Pyx_TraceLine(4625,0,__PYX_ERR(0, 4625, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_ratio}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_mean); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_ratio, __pyx_t_4); __pyx_t_4 = 0;
+4626: return ratio
__Pyx_TraceLine(4626,0,__PYX_ERR(0, 4626, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_ratio); __pyx_r = __pyx_v_ratio; goto __pyx_L0;
4627:
+4628: def assert_ratio(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_164assert_ratio(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_163assert_ratio, " Assert rate value between a specific range. \n \n Parameters \n -----------\n v: float, \n ratio value to assert \n bounds: list ( lower, upper) \n The range that value must be included\n exclude_value: float \n A value that ``v`` must not taken. Exclude it from the ``bounds``. \n Raise error otherwise. Note that any other value will use the \n lower bound in `bounds` as exlusion. \n \n in_percent: bool, default=False, \n Convert the value into a percentage.\n \n name: str, default='rate' \n the name of the value for assertion. \n \n Returns\n --------\n v: float \n Asserted value. \n \n Examples\n ---------\n >>> from gofast.tools.coreutils import assert_ratio\n >>> assert_ratio('2')\n 2.0\n >>> assert_ratio(2 , bounds =(2, 8))\n 2.0\n >>> assert_ratio(2 , bounds =(4, 8))\n ValueError:...\n >>> assert_ratio(2 , bounds =(1, 8), exclude_value =2 )\n ValueError: ...\n >>> assert_ratio(2 , bounds =(1, 8), exclude_value ='use bounds' )\n 2.0\n >>> assert_ratio(2 , bounds =(0, 1) , in_percent =True )\n 0.02\n >>> assert_ratio(2 , bounds =(0, 1) )\n ValueError:\n >>> assert_ratio(2 , bounds =(0, 1), exclude_value ='use lower bound',\n name ='tolerance', in_percent =True )\n 0.02\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_164assert_ratio = {"assert_ratio", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_164assert_ratio, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_163assert_ratio}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_164assert_ratio(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_v = 0; PyObject *__pyx_v_bounds = 0; PyObject *__pyx_v_exclude_value = 0; PyObject *__pyx_v_in_percent = 0; PyObject *__pyx_v_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("assert_ratio (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_v,&__pyx_n_s_bounds,&__pyx_n_s_exclude_value,&__pyx_n_s_in_percent,&__pyx_n_s_name_2,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_163assert_ratio(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_v, PyObject *__pyx_v_bounds, PyObject *__pyx_v_exclude_value, PyObject *__pyx_v_in_percent, PyObject *__pyx_v_name) { PyObject *__pyx_v_msg = NULL; PyObject *__pyx_v_low = NULL; PyObject *__pyx_v_up = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_v_err = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__202) __Pyx_TraceCall("assert_ratio", __pyx_f[0], 4628, 0, __PYX_ERR(0, 4628, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_v); __Pyx_INCREF(__pyx_v_bounds); __Pyx_INCREF(__pyx_v_in_percent); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils.assert_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_low); __Pyx_XDECREF(__pyx_v_up); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_err); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_bounds); __Pyx_XDECREF(__pyx_v_in_percent); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__466 = PyTuple_Pack(11, __pyx_n_s_v, __pyx_n_s_bounds, __pyx_n_s_exclude_value, __pyx_n_s_in_percent, __pyx_n_s_name_2, __pyx_n_s_msg, __pyx_n_s_low, __pyx_n_s_up, __pyx_n_s__8, __pyx_n_s_e, __pyx_n_s_err); if (unlikely(!__pyx_tuple__466)) __PYX_ERR(0, 4628, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__466); __Pyx_GIVEREF(__pyx_tuple__466); __pyx_codeobj__202 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__466, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_assert_ratio, 4628, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__202)) __PYX_ERR(0, 4628, __pyx_L1_error) /* … */ __Pyx_TraceLine(4628,0,__PYX_ERR(0, 4628, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_bounds, __pyx_kp_s_List_float) < 0) __PYX_ERR(0, 4628, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exclude_value, __pyx_n_s_float) < 0) __PYX_ERR(0, 4628, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_in_percent, __pyx_n_s_bool) < 0) __PYX_ERR(0, 4628, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_name_2, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 4628, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_164assert_ratio, 0, __pyx_n_s_assert_ratio, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__202)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__467); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_assert_ratio, __pyx_t_2) < 0) __PYX_ERR(0, 4628, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__467 = PyTuple_Pack(4, Py_None, Py_None, ((PyObject *)Py_False), ((PyObject*)__pyx_n_u_rate)); if (unlikely(!__pyx_tuple__467)) __PYX_ERR(0, 4628, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__467); __Pyx_GIVEREF(__pyx_tuple__467);
+4629: v, bounds: List[float] = None ,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4630: exclude_value:float= None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+4631: in_percent:bool =False ,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_rate))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_v)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4628, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_bounds); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4628, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exclude_value); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4628, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_in_percent); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4628, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4628, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "assert_ratio") < 0)) __PYX_ERR(0, 4628, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_v = values[0]; __pyx_v_bounds = values[1]; __pyx_v_exclude_value = ((PyObject*)values[2]); __pyx_v_in_percent = values[3]; __pyx_v_name = ((PyObject*)values[4]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("assert_ratio", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 4628, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.assert_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_exclude_value), (&PyFloat_Type), 1, "exclude_value", 1))) __PYX_ERR(0, 4630, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyUnicode_Type), 0, "name", 1))) __PYX_ERR(0, 4632, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_163assert_ratio(__pyx_self, __pyx_v_v, __pyx_v_bounds, __pyx_v_exclude_value, __pyx_v_in_percent, __pyx_v_name);
4632: name:str ='rate'
4633: ):
4634: """ Assert rate value between a specific range.
4635:
4636: Parameters
4637: -----------
4638: v: float,
4639: ratio value to assert
4640: bounds: list ( lower, upper)
4641: The range that value must be included
4642: exclude_value: float
4643: A value that ``v`` must not taken. Exclude it from the ``bounds``.
4644: Raise error otherwise. Note that any other value will use the
4645: lower bound in `bounds` as exlusion.
4646:
4647: in_percent: bool, default=False,
4648: Convert the value into a percentage.
4649:
4650: name: str, default='rate'
4651: the name of the value for assertion.
4652:
4653: Returns
4654: --------
4655: v: float
4656: Asserted value.
4657:
4658: Examples
4659: ---------
4660: >>> from gofast.tools.coreutils import assert_ratio
4661: >>> assert_ratio('2')
4662: 2.0
4663: >>> assert_ratio(2 , bounds =(2, 8))
4664: 2.0
4665: >>> assert_ratio(2 , bounds =(4, 8))
4666: ValueError:...
4667: >>> assert_ratio(2 , bounds =(1, 8), exclude_value =2 )
4668: ValueError: ...
4669: >>> assert_ratio(2 , bounds =(1, 8), exclude_value ='use bounds' )
4670: 2.0
4671: >>> assert_ratio(2 , bounds =(0, 1) , in_percent =True )
4672: 0.02
4673: >>> assert_ratio(2 , bounds =(0, 1) )
4674: ValueError:
4675: >>> assert_ratio(2 , bounds =(0, 1), exclude_value ='use lower bound',
4676: name ='tolerance', in_percent =True )
4677: 0.02
4678: """
+4679: msg =("greater than {} and less than {}" )
__Pyx_TraceLine(4679,0,__PYX_ERR(0, 4679, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_greater_than_and_less_than); __pyx_v_msg = __pyx_kp_u_greater_than_and_less_than;
4680:
4681:
+4682: if isinstance (v, str):
__Pyx_TraceLine(4682,0,__PYX_ERR(0, 4682, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_v); if (__pyx_t_1) { /* … */ }
+4683: if "%" in v: in_percent=True
__Pyx_TraceLine(4683,0,__PYX_ERR(0, 4683, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__203, __pyx_v_v, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4683, __pyx_L1_error) if (__pyx_t_1) { __Pyx_INCREF(Py_True); __Pyx_DECREF_SET(__pyx_v_in_percent, Py_True); }
+4684: v = v.replace('%', '')
__Pyx_TraceLine(4684,0,__PYX_ERR(0, 4684, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_tuple__204 = PyTuple_Pack(2, __pyx_kp_u__203, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__204)) __PYX_ERR(0, 4684, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__204); __Pyx_GIVEREF(__pyx_tuple__204);
+4685: try :
__Pyx_TraceLine(4685,0,__PYX_ERR(0, 4685, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L10_try_end:; }
+4686: v = float (v)
__Pyx_TraceLine(4686,0,__PYX_ERR(0, 4686, __pyx_L5_error)) __pyx_t_3 = __Pyx_PyNumber_Float(__pyx_v_v); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4686, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0;
+4687: except TypeError :
__Pyx_TraceLine(4687,0,__PYX_ERR(0, 4687, __pyx_L7_except_error)) __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_TypeError); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils.assert_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_8) < 0) __PYX_ERR(0, 4687, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_8);
+4688: raise TypeError (f"Unable to convert {type(v).__name__!r} "
__Pyx_TraceLine(4688,0,__PYX_ERR(0, 4688, __pyx_L7_except_error)) __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4688, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_kp_u_Unable_to_convert); __pyx_t_10 += 18; __Pyx_GIVEREF(__pyx_kp_u_Unable_to_convert); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Unable_to_convert); __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_v)), __pyx_n_s_name); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4688, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_12), __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4688, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_13); __pyx_t_13 = 0; __Pyx_INCREF(__pyx_kp_u_to_float); __pyx_t_10 += 11; __Pyx_GIVEREF(__pyx_kp_u_to_float); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u_to_float); /* … */ __Pyx_TraceLine(4688,0,__PYX_ERR(0, 4688, __pyx_L7_except_error)) __pyx_t_13 = __Pyx_PyUnicode_Join(__pyx_t_9, 4, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4688, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4688, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 4688, __pyx_L7_except_error) }
+4689: f"to float: {v}")
__Pyx_TraceLine(4689,0,__PYX_ERR(0, 4689, __pyx_L7_except_error)) __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_v_v, __pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4689, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_13); __pyx_t_13 = 0;
+4690: except ValueError:
__Pyx_TraceLine(4690,0,__PYX_ERR(0, 4690, __pyx_L7_except_error)) __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils.assert_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 4690, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3);
+4691: raise ValueError(f"Expects 'float' not {type(v).__name__!r}: "
__Pyx_TraceLine(4691,0,__PYX_ERR(0, 4691, __pyx_L7_except_error)) __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4691, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_kp_u_Expects_float_not); __pyx_t_10 += 20; __Pyx_GIVEREF(__pyx_kp_u_Expects_float_not); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Expects_float_not); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_v)), __pyx_n_s_name); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4691, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_12 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_13), __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4691, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_12); __pyx_t_12 = 0; __Pyx_INCREF(__pyx_kp_u__68); __pyx_t_10 += 2; __Pyx_GIVEREF(__pyx_kp_u__68); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u__68); /* … */ __Pyx_TraceLine(4691,0,__PYX_ERR(0, 4691, __pyx_L7_except_error)) __pyx_t_12 = __Pyx_PyUnicode_Join(__pyx_t_9, 4, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4691, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4691, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 4691, __pyx_L7_except_error) } goto __pyx_L7_except_error;
+4692: f"{(v)!r}")
__Pyx_TraceLine(4692,0,__PYX_ERR(0, 4692, __pyx_L7_except_error)) __pyx_t_12 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_v), __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4692, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_12) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_12); __pyx_t_12 = 0;
4693: # put value in percentage
4694: # if greater than 1.
+4695: if in_percent:
__Pyx_TraceLine(4695,0,__PYX_ERR(0, 4695, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_in_percent); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4695, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+4696: if 1 < v <=100:
__Pyx_TraceLine(4696,0,__PYX_ERR(0, 4696, __pyx_L1_error)) __pyx_t_3 = PyObject_RichCompare(__pyx_int_1, __pyx_v_v, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4696, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_3)) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = PyObject_RichCompare(__pyx_v_v, __pyx_int_100, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4696, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_1) { /* … */ }
+4697: v /= 100.
__Pyx_TraceLine(4697,0,__PYX_ERR(0, 4697, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyFloat_TrueDivideObjC(__pyx_v_v, __pyx_float_100_, 100., 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4697, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0;
4698:
+4699: bounds = bounds or []
__Pyx_TraceLine(4699,0,__PYX_ERR(0, 4699, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_bounds); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4699, __pyx_L1_error) if (!__pyx_t_1) { } else { __Pyx_INCREF(__pyx_v_bounds); __pyx_t_3 = __pyx_v_bounds; goto __pyx_L17_bool_binop_done; } __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_L17_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_bounds, __pyx_t_3); __pyx_t_3 = 0;
+4700: low, up, *_ = list(bounds) + [ None, None]
__Pyx_TraceLine(4700,0,__PYX_ERR(0, 4700, __pyx_L1_error)) __pyx_t_3 = PySequence_List(__pyx_v_bounds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, Py_None)) __PYX_ERR(0, 4700, __pyx_L1_error); __Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 4700, __pyx_L1_error); __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; { Py_ssize_t index = -1; PyObject** temps[3] = {&__pyx_t_2,&__pyx_t_3}; __pyx_t_9 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); for (index=0; index < 2; index++) { PyObject* item = __pyx_t_14(__pyx_t_9); if (unlikely(!item)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } goto __pyx_L20_unpacking_done; __pyx_L19_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_14 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 4700, __pyx_L1_error) __pyx_L20_unpacking_done:; } __pyx_t_12 = PySequence_List(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4700, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_low = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_up = __pyx_t_3; __pyx_t_3 = 0; __pyx_v__ = ((PyObject*)__pyx_t_12); __pyx_t_12 = 0;
+4701: e=("Expects a {} value {}, got: {}".format(
__Pyx_TraceLine(4701,0,__PYX_ERR(0, 4701, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Expects_a_value_got, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12);
+4702: name , msg.format(low, up), v))
__Pyx_TraceLine(4702,0,__PYX_ERR(0, 4702, __pyx_L1_error)) __pyx_t_3 = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_msg, __pyx_v_low, __pyx_v_up); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4702, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_v_name, __pyx_t_3, __pyx_v_v}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_7, 3+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } __pyx_v_e = __pyx_t_8; __pyx_t_8 = 0;
+4703: err = ValueError (e)
__Pyx_TraceLine(4703,0,__PYX_ERR(0, 4703, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_e); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_v_err = __pyx_t_8; __pyx_t_8 = 0;
4704:
+4705: if len(bounds)!=0:
__Pyx_TraceLine(4705,0,__PYX_ERR(0, 4705, __pyx_L1_error)) __pyx_t_10 = PyObject_Length(__pyx_v_bounds); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4705, __pyx_L1_error) __pyx_t_1 = (__pyx_t_10 != 0); if (__pyx_t_1) { /* … */ }
+4706: if (
__Pyx_TraceLine(4706,0,__PYX_ERR(0, 4706, __pyx_L1_error)) if (unlikely(__pyx_t_1)) { /* … */ }
+4707: low is not None # use is not None since 0. is
__Pyx_TraceLine(4707,0,__PYX_ERR(0, 4707, __pyx_L1_error)) __pyx_t_15 = (__pyx_v_low != Py_None); if (__pyx_t_15) { } else { __pyx_t_1 = __pyx_t_15; goto __pyx_L23_bool_binop_done; }
+4708: and up is not None # consider as False value
__Pyx_TraceLine(4708,0,__PYX_ERR(0, 4708, __pyx_L1_error)) __pyx_t_15 = (__pyx_v_up != Py_None); if (__pyx_t_15) { } else { __pyx_t_1 = __pyx_t_15; goto __pyx_L23_bool_binop_done; }
+4709: and (v < low or v > up)
__Pyx_TraceLine(4709,0,__PYX_ERR(0, 4709, __pyx_L1_error)) __pyx_t_8 = PyObject_RichCompare(__pyx_v_v, __pyx_v_low, Py_LT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4709, __pyx_L1_error) __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 4709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (!__pyx_t_15) { } else { __pyx_t_1 = __pyx_t_15; goto __pyx_L23_bool_binop_done; } __pyx_t_8 = PyObject_RichCompare(__pyx_v_v, __pyx_v_up, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4709, __pyx_L1_error) __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 4709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_1 = __pyx_t_15; __pyx_L23_bool_binop_done:;
4710: ) :
+4711: raise err
__Pyx_TraceLine(4711,0,__PYX_ERR(0, 4711, __pyx_L1_error)) __Pyx_Raise(__pyx_v_err, 0, 0, 0); __PYX_ERR(0, 4711, __pyx_L1_error)
4712:
+4713: if exclude_value is not None:
__Pyx_TraceLine(4713,0,__PYX_ERR(0, 4713, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_exclude_value != ((PyObject*)Py_None)); if (__pyx_t_1) { /* … */ }
+4714: try :
__Pyx_TraceLine(4714,0,__PYX_ERR(0, 4714, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L33_try_end; __pyx_L28_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L30_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); goto __pyx_L1_error; __pyx_L29_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_5, __pyx_t_4); __pyx_L33_try_end:; }
+4715: low = float (str(exclude_value))
__Pyx_TraceLine(4715,0,__PYX_ERR(0, 4715, __pyx_L28_error)) __pyx_t_8 = __Pyx_PyObject_Str(__pyx_v_exclude_value); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4715, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_12 = __Pyx_PyNumber_Float(__pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4715, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_low, __pyx_t_12); __pyx_t_12 = 0;
+4716: except : # use bounds
__Pyx_TraceLine(4716,0,__PYX_ERR(0, 4716, __pyx_L30_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L29_exception_handled; }
4717: pass
+4718: if low is None:
__Pyx_TraceLine(4718,0,__PYX_ERR(0, 4718, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_low == Py_None); if (__pyx_t_1) { /* … */ goto __pyx_L34; }
+4719: warnings.warn("Cannot exclude the lower value in the interval"
__Pyx_TraceLine(4719,0,__PYX_ERR(0, 4719, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_warnings); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4719, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4719, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_kp_u_Cannot_exclude_the_lower_value_i}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4719, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
4720: " while `bounds` argument is not given.")
4721: else:
+4722: if v ==low:
__Pyx_TraceLine(4722,0,__PYX_ERR(0, 4722, __pyx_L1_error)) /*else*/ { __pyx_t_12 = PyObject_RichCompare(__pyx_v_v, __pyx_v_low, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4722, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4722, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(__pyx_t_1)) { /* … */ } } __pyx_L34:;
+4723: raise ValueError (e.replace (", got:", ' excluding') + ".")
__Pyx_TraceLine(4723,0,__PYX_ERR(0, 4723, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_e, __pyx_n_s_replace); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__205, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = PyNumber_Add(__pyx_t_3, __pyx_kp_u__26); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4723, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 4723, __pyx_L1_error) /* … */ __pyx_tuple__205 = PyTuple_Pack(2, __pyx_kp_u_got, __pyx_kp_u_excluding); if (unlikely(!__pyx_tuple__205)) __PYX_ERR(0, 4723, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__205); __Pyx_GIVEREF(__pyx_tuple__205);
4724:
+4725: if in_percent and v > 100:
__Pyx_TraceLine(4725,0,__PYX_ERR(0, 4725, __pyx_L1_error)) __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_v_in_percent); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 4725, __pyx_L1_error) if (__pyx_t_15) { } else { __pyx_t_1 = __pyx_t_15; goto __pyx_L37_bool_binop_done; } __pyx_t_3 = PyObject_RichCompare(__pyx_v_v, __pyx_int_100, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4725, __pyx_L1_error) __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 4725, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_15; __pyx_L37_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+4726: raise ValueError ("{} value should be {}, got: {}".
__Pyx_TraceLine(4726,0,__PYX_ERR(0, 4726, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_value_should_be_got, __pyx_n_s_format); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); /* … */ __Pyx_TraceLine(4726,0,__PYX_ERR(0, 4726, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 4726, __pyx_L1_error)
+4727: format(name.title(), msg.format(low, up), v ))
__Pyx_TraceLine(4727,0,__PYX_ERR(0, 4727, __pyx_L1_error)) __pyx_t_8 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_title, __pyx_v_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_2 = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_msg, __pyx_v_low, __pyx_v_up); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_12))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_12, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_9, __pyx_t_8, __pyx_t_2, __pyx_v_v}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_12, __pyx_callargs+1-__pyx_t_7, 3+__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; }
+4728: return v
__Pyx_TraceLine(4728,0,__PYX_ERR(0, 4728, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_v); __pyx_r = __pyx_v_v; goto __pyx_L0;
4729:
+4730: def validate_ratio(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_166validate_ratio(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_165validate_ratio, "Validates and optionally converts a value to a percentage within \n specified bounds, excluding specific values.\n\n Parameters:\n -----------\n value : float or str\n The value to validate and convert. If a string with a '%' sign, \n conversion to percentage is attempted.\n bounds : tuple of float, optional\n A tuple specifying the lower and upper bounds (inclusive) for the value. \n If None, no bounds are enforced.\n exclude : float, optional\n A specific value to exclude from the valid range. If the value matches \n 'exclude', a ValueError is raised.\n to_percent : bool, default=False\n If True, the value is converted to a percentage \n (assumed to be in the range [0, 100]).\n param_name : str, default='value'\n The parameter name to use in error messages.\n\n Returns:\n --------\n float\n The validated (and possibly converted) value.\n\n Raises:\n ------\n ValueError\n If the value is outside the specified bounds, matches the 'exclude' \n value, or cannot be converted as specified.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_166validate_ratio = {"validate_ratio", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_166validate_ratio, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_165validate_ratio}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_166validate_ratio(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { double __pyx_v_value; PyObject *__pyx_v_bounds = 0; PyObject *__pyx_v_exclude = 0; PyObject *__pyx_v_to_percent = 0; PyObject *__pyx_v_param_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("validate_ratio (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,&__pyx_n_s_bounds,&__pyx_n_s_exclude,&__pyx_n_s_to_percent,&__pyx_n_s_param_name,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_165validate_ratio(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_value, PyObject *__pyx_v_bounds, PyObject *__pyx_v_exclude, PyObject *__pyx_v_to_percent, PyObject *__pyx_v_param_name) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__206) __Pyx_TraceCall("validate_ratio", __pyx_f[0], 4730, 0, __PYX_ERR(0, 4730, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_to_percent); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_AddTraceback("gofast.tools.coreutils.validate_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_to_percent); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__468 = PyTuple_Pack(5, __pyx_n_s_value, __pyx_n_s_bounds, __pyx_n_s_exclude, __pyx_n_s_to_percent, __pyx_n_s_param_name); if (unlikely(!__pyx_tuple__468)) __PYX_ERR(0, 4730, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__468); __Pyx_GIVEREF(__pyx_tuple__468); __pyx_codeobj__206 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__468, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_ratio, 4730, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__206)) __PYX_ERR(0, 4730, __pyx_L1_error) /* … */ __Pyx_TraceLine(4730,0,__PYX_ERR(0, 4730, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_value, __pyx_n_s_float) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_bounds, __pyx_kp_s_Optional_Tuple_float_float) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exclude, __pyx_kp_s_Optional_float) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_to_percent, __pyx_n_s_bool) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_param_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_float) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_166validate_ratio, 0, __pyx_n_s_validate_ratio, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__206)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__469); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_ratio, __pyx_t_5) < 0) __PYX_ERR(0, 4730, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__469 = PyTuple_Pack(4, Py_None, Py_None, ((PyObject *)Py_False), ((PyObject*)__pyx_n_u_value)); if (unlikely(!__pyx_tuple__469)) __PYX_ERR(0, 4730, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__469); __Pyx_GIVEREF(__pyx_tuple__469);
4731: value: float,
+4732: bounds: Optional[Tuple[float, float]] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4733: exclude: Optional[float] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4734: to_percent: bool = False,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_value))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4730, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_bounds); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4730, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exclude); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4730, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_to_percent); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4730, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_param_name); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4730, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "validate_ratio") < 0)) __PYX_ERR(0, 4730, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_value = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_value == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 4731, __pyx_L3_error) __pyx_v_bounds = values[1]; __pyx_v_exclude = values[2]; __pyx_v_to_percent = values[3]; __pyx_v_param_name = ((PyObject*)values[4]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("validate_ratio", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 4730, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.validate_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_param_name), (&PyUnicode_Type), 0, "param_name", 1))) __PYX_ERR(0, 4735, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_165validate_ratio(__pyx_self, __pyx_v_value, __pyx_v_bounds, __pyx_v_exclude, __pyx_v_to_percent, __pyx_v_param_name);
4735: param_name: str = 'value'
4736: ) -> float:
4737: """Validates and optionally converts a value to a percentage within
4738: specified bounds, excluding specific values.
4739:
4740: Parameters:
4741: -----------
4742: value : float or str
4743: The value to validate and convert. If a string with a '%' sign,
4744: conversion to percentage is attempted.
4745: bounds : tuple of float, optional
4746: A tuple specifying the lower and upper bounds (inclusive) for the value.
4747: If None, no bounds are enforced.
4748: exclude : float, optional
4749: A specific value to exclude from the valid range. If the value matches
4750: 'exclude', a ValueError is raised.
4751: to_percent : bool, default=False
4752: If True, the value is converted to a percentage
4753: (assumed to be in the range [0, 100]).
4754: param_name : str, default='value'
4755: The parameter name to use in error messages.
4756:
4757: Returns:
4758: --------
4759: float
4760: The validated (and possibly converted) value.
4761:
4762: Raises:
4763: ------
4764: ValueError
4765: If the value is outside the specified bounds, matches the 'exclude'
4766: value, or cannot be converted as specified.
4767: """
+4768: if isinstance(value, str) and '%' in value:
__Pyx_TraceLine(4768,0,__PYX_ERR(0, 4768, __pyx_L1_error)) __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyUnicode_Check(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__203, __pyx_t_2, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4768, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+4769: to_percent = True
__Pyx_TraceLine(4769,0,__PYX_ERR(0, 4769, __pyx_L1_error)) __Pyx_INCREF(Py_True); __Pyx_DECREF_SET(__pyx_v_to_percent, Py_True);
+4770: value = value.replace('%', '')
__Pyx_TraceLine(4770,0,__PYX_ERR(0, 4770, __pyx_L1_error)) __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_replace); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 4770, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_value = __pyx_t_5;
+4771: try:
__Pyx_TraceLine(4771,0,__PYX_ERR(0, 4771, __pyx_L1_error)) { /*try:*/ { /* … */ __Pyx_TraceLine(4772,0,__PYX_ERR(0, 4772, __pyx_L6_error)) } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L11_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L11_try_end:; }
4772: value = float(value)
+4773: except ValueError:
__Pyx_TraceLine(4773,0,__PYX_ERR(0, 4773, __pyx_L8_except_error)) __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_9) { __Pyx_AddTraceback("gofast.tools.coreutils.validate_ratio", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_4, &__pyx_t_10) < 0) __PYX_ERR(0, 4773, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_10);
+4774: raise ValueError(f"Expected a float, got {type(value).__name__}: {value}")
__Pyx_TraceLine(4774,0,__PYX_ERR(0, 4774, __pyx_L8_except_error)) __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Expected_a_float_got); __pyx_t_12 += 22; __Pyx_GIVEREF(__pyx_kp_u_Expected_a_float_got); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_kp_u_Expected_a_float_got); __pyx_t_14 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_t_14)), __pyx_n_s_name); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_15, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u__68); __pyx_t_12 += 2; __Pyx_GIVEREF(__pyx_kp_u__68); PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_kp_u__68); __pyx_t_14 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_t_14, __pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15); __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_11, 4, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4774, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 4774, __pyx_L8_except_error) } goto __pyx_L8_except_error;
4775:
+4776: if to_percent and 0 < value <= 100:
__Pyx_TraceLine(4776,0,__PYX_ERR(0, 4776, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_to_percent); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4776, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L15_bool_binop_done; } __pyx_t_3 = (0.0 < __pyx_v_value); if (__pyx_t_3) { __pyx_t_3 = (__pyx_v_value <= 100.0); } __pyx_t_1 = __pyx_t_3; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+4777: value /= 100
__Pyx_TraceLine(4777,0,__PYX_ERR(0, 4777, __pyx_L1_error)) __pyx_v_value = (__pyx_v_value / 100.0);
4778:
+4779: if bounds:
__Pyx_TraceLine(4779,0,__PYX_ERR(0, 4779, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_bounds); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4779, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+4780: if not (bounds[0] <= value <= bounds[1]):
__Pyx_TraceLine(4780,0,__PYX_ERR(0, 4780, __pyx_L1_error)) __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyObject_RichCompare(__pyx_t_10, __pyx_t_4, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4780, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_2)) { __Pyx_DECREF(__pyx_t_2); __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_bounds, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4780, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_t_11, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4780, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4780, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (!__pyx_t_1); if (unlikely(__pyx_t_3)) { /* … */ }
+4781: raise ValueError(f"{param_name} must be between {bounds[0]}"
__Pyx_TraceLine(4781,0,__PYX_ERR(0, 4781, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_v_param_name); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_param_name) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_param_name) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_param_name); __Pyx_GIVEREF(__pyx_v_param_name); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_param_name); __Pyx_INCREF(__pyx_kp_u_must_be_between); __pyx_t_12 += 17; __Pyx_GIVEREF(__pyx_kp_u_must_be_between); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u_must_be_between); __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_kp_u_and_2); __pyx_t_12 += 5; __Pyx_GIVEREF(__pyx_kp_u_and_2); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_kp_u_and_2); /* … */ __Pyx_TraceLine(4781,0,__PYX_ERR(0, 4781, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_2, 7, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4781, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 4781, __pyx_L1_error)
+4782: f" and {bounds[1]}, got: {value}")
__Pyx_TraceLine(4782,0,__PYX_ERR(0, 4782, __pyx_L1_error)) __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_bounds, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_10, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_got_2); __pyx_t_12 += 7; __Pyx_GIVEREF(__pyx_kp_u_got_2); PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_kp_u_got_2); __pyx_t_4 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4782, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 6, __pyx_t_10); __pyx_t_10 = 0;
4783:
+4784: if exclude is not None and value == exclude:
__Pyx_TraceLine(4784,0,__PYX_ERR(0, 4784, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_exclude != Py_None); if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L20_bool_binop_done; } __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4784, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = PyObject_RichCompare(__pyx_t_2, __pyx_v_exclude, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4784, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4784, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_3 = __pyx_t_1; __pyx_L20_bool_binop_done:; if (unlikely(__pyx_t_3)) { /* … */ }
+4785: raise ValueError(f"{param_name} cannot be {exclude}")
__Pyx_TraceLine(4785,0,__PYX_ERR(0, 4785, __pyx_L1_error)) __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_v_param_name); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_param_name) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_param_name) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_param_name); __Pyx_GIVEREF(__pyx_v_param_name); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_param_name); __Pyx_INCREF(__pyx_kp_u_cannot_be); __pyx_t_12 += 11; __Pyx_GIVEREF(__pyx_kp_u_cannot_be); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_kp_u_cannot_be); __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_exclude, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 4785, __pyx_L1_error)
4786:
+4787: if to_percent and value > 1:
__Pyx_TraceLine(4787,0,__PYX_ERR(0, 4787, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_to_percent); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4787, __pyx_L1_error) if (__pyx_t_1) { } else { __pyx_t_3 = __pyx_t_1; goto __pyx_L23_bool_binop_done; } __pyx_t_1 = (__pyx_v_value > 1.0); __pyx_t_3 = __pyx_t_1; __pyx_L23_bool_binop_done:; if (unlikely(__pyx_t_3)) { /* … */ }
+4788: raise ValueError(f"{param_name} converted to percent must"
__Pyx_TraceLine(4788,0,__PYX_ERR(0, 4788, __pyx_L1_error)) __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_v_param_name); __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_param_name) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_param_name) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_param_name); __Pyx_GIVEREF(__pyx_v_param_name); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_param_name); __Pyx_INCREF(__pyx_kp_u_converted_to_percent_must_not_e); __pyx_t_12 += 46; __Pyx_GIVEREF(__pyx_kp_u_converted_to_percent_must_not_e); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_kp_u_converted_to_percent_must_not_e); /* … */ __Pyx_TraceLine(4788,0,__PYX_ERR(0, 4788, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_12, __pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4788, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 4788, __pyx_L1_error)
+4789: f" not exceed 1, got: {value}")
__Pyx_TraceLine(4789,0,__PYX_ERR(0, 4789, __pyx_L1_error)) __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4789, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_13; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4); __pyx_t_4 = 0;
4790:
+4791: return value
__Pyx_TraceLine(4791,0,__PYX_ERR(0, 4791, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4791, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0;
4792:
+4793: def exist_features (df, features, error='raise', name="Feature"):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_168exist_features(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_167exist_features, "Control whether the features exist or not. \n \n :param df: a dataframe for features selections \n :param features: list of features to select. Lits of features must be in the \n dataframe otherwise an error occurs. \n :param error: str - raise if the features don't exist in the dataframe. \n *default* is ``raise`` and ``ignore`` otherwise. \n \n :return: bool \n assert whether the features exists \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_168exist_features = {"exist_features", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_168exist_features, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_167exist_features}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_168exist_features(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_features = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("exist_features (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_features,&__pyx_n_s_error,&__pyx_n_s_name_2,0}; PyObject* values[4] = {0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_raise))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_Feature))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4793, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_features)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4793, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("exist_features", 0, 2, 4, 1); __PYX_ERR(0, 4793, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_error); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4793, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4793, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "exist_features") < 0)) __PYX_ERR(0, 4793, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_df = values[0]; __pyx_v_features = values[1]; __pyx_v_error = values[2]; __pyx_v_name = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("exist_features", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 4793, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.exist_features", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_167exist_features(__pyx_self, __pyx_v_df, __pyx_v_features, __pyx_v_error, __pyx_v_name); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_167exist_features(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_features, PyObject *__pyx_v_error, PyObject *__pyx_v_name) { int __pyx_v_isf; PyObject *__pyx_v_set_f = NULL; Py_ssize_t __pyx_v_nfeat; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_v_diff = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__207) __Pyx_TraceCall("exist_features", __pyx_f[0], 4793, 0, __PYX_ERR(0, 4793, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_features); __Pyx_INCREF(__pyx_v_error); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.exist_features", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_set_f); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_diff); __Pyx_XDECREF(__pyx_v_features); __Pyx_XDECREF(__pyx_v_error); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__470 = PyTuple_Pack(9, __pyx_n_s_df, __pyx_n_s_features, __pyx_n_s_error, __pyx_n_s_name_2, __pyx_n_s_isf, __pyx_n_s_set_f, __pyx_n_s_nfeat, __pyx_n_s_msg, __pyx_n_s_diff); if (unlikely(!__pyx_tuple__470)) __PYX_ERR(0, 4793, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__470); __Pyx_GIVEREF(__pyx_tuple__470); __pyx_codeobj__207 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__470, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_exist_features, 4793, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__207)) __PYX_ERR(0, 4793, __pyx_L1_error) /* … */ __Pyx_TraceLine(4793,0,__PYX_ERR(0, 4793, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_168exist_features, 0, __pyx_n_s_exist_features, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__207)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4793, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__471); if (PyDict_SetItem(__pyx_d, __pyx_n_s_exist_features, __pyx_t_5) < 0) __PYX_ERR(0, 4793, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__471 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u_raise), ((PyObject*)__pyx_n_u_Feature)); if (unlikely(!__pyx_tuple__471)) __PYX_ERR(0, 4793, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__471); __Pyx_GIVEREF(__pyx_tuple__471);
4794: """Control whether the features exist or not.
4795:
4796: :param df: a dataframe for features selections
4797: :param features: list of features to select. Lits of features must be in the
4798: dataframe otherwise an error occurs.
4799: :param error: str - raise if the features don't exist in the dataframe.
4800: *default* is ``raise`` and ``ignore`` otherwise.
4801:
4802: :return: bool
4803: assert whether the features exists
4804: """
+4805: isf = False
__Pyx_TraceLine(4805,0,__PYX_ERR(0, 4805, __pyx_L1_error)) __pyx_v_isf = 0;
4806:
+4807: error= 'raise' if error.lower().strip().find('raise')>= 0 else 'ignore'
__Pyx_TraceLine(4807,0,__PYX_ERR(0, 4807, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_error, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strip); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_find); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_raise}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4807, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_8) { __Pyx_INCREF(__pyx_n_u_raise); __pyx_t_1 = __pyx_n_u_raise; } else { __Pyx_INCREF(__pyx_n_u_ignore); __pyx_t_1 = __pyx_n_u_ignore; } __Pyx_DECREF_SET(__pyx_v_error, __pyx_t_1); __pyx_t_1 = 0;
4808:
+4809: if isinstance(features, str):
__Pyx_TraceLine(4809,0,__PYX_ERR(0, 4809, __pyx_L1_error)) __pyx_t_8 = PyUnicode_Check(__pyx_v_features); if (__pyx_t_8) { /* … */ }
+4810: features =[features]
__Pyx_TraceLine(4810,0,__PYX_ERR(0, 4810, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_features); __Pyx_GIVEREF(__pyx_v_features); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_features)) __PYX_ERR(0, 4810, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_features, __pyx_t_1); __pyx_t_1 = 0;
4811:
+4812: features = _assert_all_types(features, list, tuple, np.ndarray)
__Pyx_TraceLine(4812,0,__PYX_ERR(0, 4812, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_2, __pyx_v_features, ((PyObject *)(&PyList_Type)), ((PyObject *)(&PyTuple_Type)), __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4812, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_features, __pyx_t_1); __pyx_t_1 = 0;
+4813: set_f = set (features).intersection (set(df.columns))
__Pyx_TraceLine(4813,0,__PYX_ERR(0, 4813, __pyx_L1_error)) __pyx_t_5 = PySet_New(__pyx_v_features); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_intersection); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_columns); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PySet_New(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_2}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4813, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_set_f = __pyx_t_1; __pyx_t_1 = 0;
+4814: if len(set_f)!= len(features):
__Pyx_TraceLine(4814,0,__PYX_ERR(0, 4814, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_set_f); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4814, __pyx_L1_error) __pyx_t_10 = PyObject_Length(__pyx_v_features); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4814, __pyx_L1_error) __pyx_t_8 = (__pyx_t_9 != __pyx_t_10); if (__pyx_t_8) { /* … */ goto __pyx_L4; }
+4815: nfeat= len(features)
__Pyx_TraceLine(4815,0,__PYX_ERR(0, 4815, __pyx_L1_error)) __pyx_t_10 = PyObject_Length(__pyx_v_features); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4815, __pyx_L1_error) __pyx_v_nfeat = __pyx_t_10;
+4816: msg = f"{name}{'s' if nfeat >1 else ''}"
__Pyx_TraceLine(4816,0,__PYX_ERR(0, 4816, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = (__pyx_v_nfeat > 1); if (__pyx_t_8) { __Pyx_INCREF(__pyx_n_u_s_2); __pyx_t_3 = __pyx_n_u_s_2; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_3 = __pyx_kp_u__22; } __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4816, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+4817: if len(set_f)==0:
__Pyx_TraceLine(4817,0,__PYX_ERR(0, 4817, __pyx_L1_error)) __pyx_t_10 = PyObject_Length(__pyx_v_set_f); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4817, __pyx_L1_error) __pyx_t_8 = (__pyx_t_10 == 0); if (__pyx_t_8) { /* … */ }
+4818: if error =='raise':
__Pyx_TraceLine(4818,0,__PYX_ERR(0, 4818, __pyx_L1_error)) __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4818, __pyx_L1_error) if (unlikely(__pyx_t_8)) { /* … */ }
+4819: raise ValueError (f"{msg} {smart_format(features)} "
__Pyx_TraceLine(4819,0,__PYX_ERR(0, 4819, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_v_msg); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_msg) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_msg) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_msg); __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_10 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u__14); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_features}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_10 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_u__14); /* … */ __Pyx_TraceLine(4819,0,__PYX_ERR(0, 4819, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_3, 6, __pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 4819, __pyx_L1_error)
+4820: f"{'does not' if nfeat <2 else 'dont'}"
__Pyx_TraceLine(4820,0,__PYX_ERR(0, 4820, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_nfeat < 2); if (__pyx_t_8) { __Pyx_INCREF(__pyx_kp_u_does_not); __pyx_t_1 = __pyx_kp_u_does_not; } else { __Pyx_INCREF(__pyx_n_u_dont); __pyx_t_1 = __pyx_n_u_dont; } __pyx_t_2 = __Pyx_PyUnicode_Unicode(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_11; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_exist_in_the_dataframe); __pyx_t_10 += 23; __Pyx_GIVEREF(__pyx_kp_u_exist_in_the_dataframe); PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_kp_u_exist_in_the_dataframe);
4821: " exist in the dataframe")
+4822: isf = False
__Pyx_TraceLine(4822,0,__PYX_ERR(0, 4822, __pyx_L1_error)) __pyx_v_isf = 0;
4823: # get the difference
+4824: diff = set (features).difference(set_f) if len(
__Pyx_TraceLine(4824,0,__PYX_ERR(0, 4824, __pyx_L1_error)) __pyx_t_10 = PyObject_Length(__pyx_v_features); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4824, __pyx_L1_error) /* … */ __Pyx_TraceLine(4824,0,__PYX_ERR(0, 4824, __pyx_L1_error)) __pyx_t_1 = PySet_New(__pyx_v_features); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_difference); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_set_f}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else {
+4825: features)> len(set_f) else set_f.difference (set(features))
__Pyx_TraceLine(4825,0,__PYX_ERR(0, 4825, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_set_f); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4825, __pyx_L1_error) __pyx_t_8 = (__pyx_t_10 > __pyx_t_9); if (__pyx_t_8) { /* … */ __Pyx_TraceLine(4825,0,__PYX_ERR(0, 4825, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_set_f, __pyx_n_s_difference); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PySet_New(__pyx_v_features); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_1}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_v_diff = __pyx_t_3; __pyx_t_3 = 0;
+4826: nfeat= len(diff)
__Pyx_TraceLine(4826,0,__PYX_ERR(0, 4826, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_diff); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4826, __pyx_L1_error) __pyx_v_nfeat = __pyx_t_9;
+4827: if error =='raise':
__Pyx_TraceLine(4827,0,__PYX_ERR(0, 4827, __pyx_L1_error)) __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4827, __pyx_L1_error) if (unlikely(__pyx_t_8)) { /* … */ }
+4828: raise ValueError(f"{msg} {smart_format(diff)} not found in"
__Pyx_TraceLine(4828,0,__PYX_ERR(0, 4828, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_v_msg); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_msg) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_msg) : __pyx_t_11; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_msg); __Pyx_GIVEREF(__pyx_v_msg); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_msg); __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_9 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_kp_u__14); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_diff}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_11; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_not_found_in_the_dataframe); __pyx_t_9 += 28; __Pyx_GIVEREF(__pyx_kp_u_not_found_in_the_dataframe); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_kp_u_not_found_in_the_dataframe); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_3, 4, __pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 4828, __pyx_L1_error)
4829: " the dataframe.")
+4830: isf = False
__Pyx_TraceLine(4830,0,__PYX_ERR(0, 4830, __pyx_L1_error)) __pyx_v_isf = 0;
+4831: else : isf = True
__Pyx_TraceLine(4831,0,__PYX_ERR(0, 4831, __pyx_L1_error)) /*else*/ { __pyx_v_isf = 1; } __pyx_L4:;
4832:
+4833: return isf
__Pyx_TraceLine(4833,0,__PYX_ERR(0, 4833, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_isf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
4834:
4835:
4836:
+4837: def random_selector (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_170random_selector(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_169random_selector, "Randomly select the number of values in array. \n \n Parameters\n ------------\n arr: ArrayLike \n Array of values \n value: float, arraylike \n If ``float`` value is passed, it indicates the number of values to \n select among the length of `arr`. If array (``value``) is passed, it\n should be self contain in the given ``arr`. However if ``string`` is \n given and contain the ``%``, it calculates the ratio of \n number to randomly select. \n seed: int, Optional \n Allow retrieving the identical value randomly selected in the given \n array. \n \n suffle: bool, False \n If ``True`` , shuffle the selected values. \n \n Returns \n --------\n arr: Array containing the selected values \n \n Examples \n ----------\n >>> import numpy as np \n >>> from gofast.tools.coreutils import random_selector \n >>> dat= np.arange (42 ) \n >>> random_selector (dat , 7, seed = 42 ) \n array([0, 1, 2, 3, 4, 5, 6])\n >>> random_selector ( dat, ( 23, 13 , 7))\n array([ 7, 13, 23])\n >>> random_selector ( dat , \"7%\", seed =42 )\n array([0, 1])\n >>> random_selector ( dat , \"70%\", seed =42 , shuffle =True )\n array([ 0, 5, 20, 25, 13, 7, 22, 10, 12, 27, 23, 21, 16, 3, 1, 17, 8,\n 6, 4, 2, 19, 11, 18, 24, 14, 15, 9, 28, 26])\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_170random_selector = {"random_selector", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_170random_selector, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_169random_selector}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_170random_selector(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_value = 0; PyObject *__pyx_v_seed = 0; PyObject *__pyx_v_shuffle = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("random_selector (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_value,&__pyx_n_s_seed,&__pyx_n_s_shuffle,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_169random_selector(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_value, PyObject *__pyx_v_seed, PyObject *__pyx_v_shuffle) { PyObject *__pyx_v_msg = NULL; PyObject *__pyx_v_v = NULL; PyObject *__pyx_v_mask = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__208) __Pyx_TraceCall("random_selector", __pyx_f[0], 4837, 0, __PYX_ERR(0, 4837, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_arr); __Pyx_INCREF(__pyx_v_value); __Pyx_INCREF(__pyx_v_seed); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_16); __Pyx_AddTraceback("gofast.tools.coreutils.random_selector", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_mask); __Pyx_XDECREF(__pyx_v_arr); __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_seed); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__472 = PyTuple_Pack(7, __pyx_n_s_arr, __pyx_n_s_value, __pyx_n_s_seed, __pyx_n_s_shuffle, __pyx_n_s_msg, __pyx_n_s_v, __pyx_n_s_mask); if (unlikely(!__pyx_tuple__472)) __PYX_ERR(0, 4837, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__472); __Pyx_GIVEREF(__pyx_tuple__472); __pyx_codeobj__208 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__472, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_random_selector, 4837, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__208)) __PYX_ERR(0, 4837, __pyx_L1_error) /* … */ __Pyx_TraceLine(4837,0,__PYX_ERR(0, 4837, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_arr, __pyx_n_s_ArrayLike) < 0) __PYX_ERR(0, 4837, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_value, __pyx_kp_s_Union_float_ArrayLike) < 0) __PYX_ERR(0, 4837, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_seed, __pyx_n_s_int) < 0) __PYX_ERR(0, 4837, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_170random_selector, 0, __pyx_n_s_random_selector, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__208)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4837, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__473); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_random_selector, __pyx_t_2) < 0) __PYX_ERR(0, 4837, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__473 = PyTuple_Pack(2, Py_None, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__473)) __PYX_ERR(0, 4837, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__473); __Pyx_GIVEREF(__pyx_tuple__473);
4838: arr:ArrayLike, value: Union [float, ArrayLike],
+4839: seed: int = None, shuffle =False ):
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4837, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4837, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("random_selector", 0, 2, 4, 1); __PYX_ERR(0, 4837, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_seed); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4837, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shuffle); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4837, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "random_selector") < 0)) __PYX_ERR(0, 4837, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_value = values[1]; __pyx_v_seed = ((PyObject*)values[2]); __pyx_v_shuffle = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("random_selector", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 4837, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.random_selector", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_seed), (&PyInt_Type), 1, "seed", 1))) __PYX_ERR(0, 4839, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_169random_selector(__pyx_self, __pyx_v_arr, __pyx_v_value, __pyx_v_seed, __pyx_v_shuffle);
4840: """Randomly select the number of values in array.
4841:
4842: Parameters
4843: ------------
4844: arr: ArrayLike
4845: Array of values
4846: value: float, arraylike
4847: If ``float`` value is passed, it indicates the number of values to
4848: select among the length of `arr`. If array (``value``) is passed, it
4849: should be self contain in the given ``arr`. However if ``string`` is
4850: given and contain the ``%``, it calculates the ratio of
4851: number to randomly select.
4852: seed: int, Optional
4853: Allow retrieving the identical value randomly selected in the given
4854: array.
4855:
4856: suffle: bool, False
4857: If ``True`` , shuffle the selected values.
4858:
4859: Returns
4860: --------
4861: arr: Array containing the selected values
4862:
4863: Examples
4864: ----------
4865: >>> import numpy as np
4866: >>> from gofast.tools.coreutils import random_selector
4867: >>> dat= np.arange (42 )
4868: >>> random_selector (dat , 7, seed = 42 )
4869: array([0, 1, 2, 3, 4, 5, 6])
4870: >>> random_selector ( dat, ( 23, 13 , 7))
4871: array([ 7, 13, 23])
4872: >>> random_selector ( dat , "7%", seed =42 )
4873: array([0, 1])
4874: >>> random_selector ( dat , "70%", seed =42 , shuffle =True )
4875: array([ 0, 5, 20, 25, 13, 7, 22, 10, 12, 27, 23, 21, 16, 3, 1, 17, 8,
4876: 6, 4, 2, 19, 11, 18, 24, 14, 15, 9, 28, 26])
4877: """
4878:
+4879: msg = "Non-numerical is not allowed. Got {!r}."
__Pyx_TraceLine(4879,0,__PYX_ERR(0, 4879, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_Non_numerical_is_not_allowed_Got); __pyx_v_msg = __pyx_kp_u_Non_numerical_is_not_allowed_Got;
4880:
+4881: if seed:
__Pyx_TraceLine(4881,0,__PYX_ERR(0, 4881, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_seed); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4881, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+4882: seed = _assert_all_types(seed , int, float, objname ='Seed')
__Pyx_TraceLine(4882,0,__PYX_ERR(0, 4882, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_seed); __Pyx_GIVEREF(__pyx_v_seed); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_seed)) __PYX_ERR(0, 4882, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 4882, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 4882, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_objname, __pyx_n_u_Seed) < 0) __PYX_ERR(0, 4882, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_5))) __PYX_ERR(0, 4882, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_seed, ((PyObject*)__pyx_t_5)); __pyx_t_5 = 0;
+4883: np.random.seed (seed )
__Pyx_TraceLine(4883,0,__PYX_ERR(0, 4883, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_seed); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_seed}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4884:
+4885: v = copy.deepcopy(value )
__Pyx_TraceLine(4885,0,__PYX_ERR(0, 4885, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_value}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4885, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_v = __pyx_t_5; __pyx_t_5 = 0;
4886:
+4887: if not is_iterable( value, exclude_string= True ):
__Pyx_TraceLine(4887,0,__PYX_ERR(0, 4887, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4887, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4887, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_value)) __PYX_ERR(0, 4887, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4887, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 4887, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4887, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4887, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (!__pyx_t_1); if (__pyx_t_7) { /* … */ }
4888:
+4889: value = str(value )
__Pyx_TraceLine(4889,0,__PYX_ERR(0, 4889, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2); __pyx_t_2 = 0;
4890:
+4891: if '%' in value:
__Pyx_TraceLine(4891,0,__PYX_ERR(0, 4891, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__203, __pyx_v_value, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4891, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+4892: try:
__Pyx_TraceLine(4892,0,__PYX_ERR(0, 4892, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L11_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L11_try_end:; }
+4893: value = float( value.replace ('%', '')) /100
__Pyx_TraceLine(4893,0,__PYX_ERR(0, 4893, __pyx_L6_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4893, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4893, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__pyx_t_11 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 4893, __pyx_L6_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyFloat_FromDouble((__pyx_t_11 / 100.0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4893, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_4); __pyx_t_4 = 0;
+4894: except :
__Pyx_TraceLine(4894,0,__PYX_ERR(0, 4894, __pyx_L8_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.random_selector", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 4894, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3);
+4895: raise TypeError(msg.format(v))
__Pyx_TraceLine(4895,0,__PYX_ERR(0, 4895, __pyx_L8_except_error)) __pyx_t_5 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_msg, __pyx_v_v); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4895, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4895, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 4895, __pyx_L8_except_error) }
4896: # get the number
+4897: value *= len(arr )
__Pyx_TraceLine(4897,0,__PYX_ERR(0, 4897, __pyx_L1_error)) __pyx_t_13 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4897, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_InPlaceMultiply(__pyx_v_value, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2); __pyx_t_2 = 0;
4898:
4899:
+4900: try :
__Pyx_TraceLine(4900,0,__PYX_ERR(0, 4900, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L19_try_end; __pyx_L14_error:; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L16_except_error:; __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_9, __pyx_t_8); goto __pyx_L1_error; __pyx_L19_try_end:; }
+4901: value = int(value )
__Pyx_TraceLine(4901,0,__PYX_ERR(0, 4901, __pyx_L14_error)) __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4901, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2); __pyx_t_2 = 0;
4902:
+4903: except :
__Pyx_TraceLine(4903,0,__PYX_ERR(0, 4903, __pyx_L16_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.random_selector", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 4903, __pyx_L16_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4);
+4904: raise TypeError (msg.format(v))
__Pyx_TraceLine(4904,0,__PYX_ERR(0, 4904, __pyx_L16_except_error)) __pyx_t_12 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_msg, __pyx_v_v); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4904, __pyx_L16_except_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4904, __pyx_L16_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 4904, __pyx_L16_except_error) }
4905:
+4906: if value > len(arr):
__Pyx_TraceLine(4906,0,__PYX_ERR(0, 4906, __pyx_L1_error)) __pyx_t_13 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4906, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_v_value, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4906, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4906, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__pyx_t_7)) { /* … */ }
+4907: raise ValueError(f"Number {value} is out of the range."
__Pyx_TraceLine(4907,0,__PYX_ERR(0, 4907, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Number); __pyx_t_13 += 7; __Pyx_GIVEREF(__pyx_kp_u_Number); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Number); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_value, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_is_out_of_the_range_Expect_valu); __pyx_t_13 += 45; __Pyx_GIVEREF(__pyx_kp_u_is_out_of_the_range_Expect_valu); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_is_out_of_the_range_Expect_valu); /* … */ __Pyx_TraceLine(4907,0,__PYX_ERR(0, 4907, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_3, 5, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 4907, __pyx_L1_error)
+4908: f" Expect value less than {len(arr)}.")
__Pyx_TraceLine(4908,0,__PYX_ERR(0, 4908, __pyx_L1_error)) __pyx_t_15 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4908, __pyx_L1_error) __pyx_t_4 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_t_15, 0, ' ', 'd'); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_13 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u__26);
4909:
+4910: value = np.random.permutation(value )
__Pyx_TraceLine(4910,0,__PYX_ERR(0, 4910, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_permutation); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_value}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_3); __pyx_t_3 = 0;
4911:
+4912: arr = np.array (
__Pyx_TraceLine(4912,0,__PYX_ERR(0, 4912, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+4913: is_iterable( arr, exclude_string=True, transform =True ))
__Pyx_TraceLine(4913,0,__PYX_ERR(0, 4913, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_arr); __Pyx_GIVEREF(__pyx_v_arr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_arr)) __PYX_ERR(0, 4913, __pyx_L1_error); __pyx_t_12 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 4913, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 4913, __pyx_L1_error) __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_16}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_3); __pyx_t_3 = 0;
4914:
+4915: arr = arr.ravel() if arr.ndim !=1 else arr
__Pyx_TraceLine(4915,0,__PYX_ERR(0, 4915, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4915, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_7) { __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ravel); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_12 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_v_arr); __pyx_t_3 = __pyx_v_arr; } __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_3); __pyx_t_3 = 0;
4916:
+4917: mask = _isin (arr, value , return_mask= True )
__Pyx_TraceLine(4917,0,__PYX_ERR(0, 4917, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_isin_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_arr); __Pyx_GIVEREF(__pyx_v_arr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_arr)) __PYX_ERR(0, 4917, __pyx_L1_error); __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value)) __PYX_ERR(0, 4917, __pyx_L1_error); __pyx_t_16 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_return_mask, Py_True) < 0) __PYX_ERR(0, 4917, __pyx_L1_error) __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_16); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_v_mask = __pyx_t_12; __pyx_t_12 = 0;
+4918: arr = arr [mask ]
__Pyx_TraceLine(4918,0,__PYX_ERR(0, 4918, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_v_mask); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF_SET(__pyx_v_arr, __pyx_t_12); __pyx_t_12 = 0;
4919:
+4920: if shuffle : np.random.shuffle (arr )
__Pyx_TraceLine(4920,0,__PYX_ERR(0, 4920, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4920, __pyx_L1_error) if (__pyx_t_7) { __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_n_s_np); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_shuffle); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_arr}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; }
4921:
+4922: return arr
__Pyx_TraceLine(4922,0,__PYX_ERR(0, 4922, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arr); __pyx_r = __pyx_v_arr; goto __pyx_L0;
4923:
+4924: def cleaner(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_172cleaner(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_171cleaner, " Sanitize data or columns by dropping specified labels \n from rows or columns. \n \n If data is not a pandas dataframe, should be converted to \n dataframe and uses index to drop the labels. \n \n Parameters \n -----------\n data: pd.Dataframe or arraylike2D. \n Dataframe pandas or Numpy two dimensional arrays. If 2D array is \n passed, it should prior be converted to a daframe by default and \n drop row index from index parameters \n \n columns: single label or list-like\n Alternative to specifying axis (\n labels, axis=1 is equivalent to columns=labels).\n\n labels: single label or list-like\n Index or column labels to drop. A tuple will be used as a single \n label and not treated as a list-like.\n\n func: _F, callable \n Universal function used to clean the columns. If performs only when \n `mode` is on ``clean`` option. \n \n inplace: bool, default False\n If False, return a copy. Otherwise, do operation \n inplace and return None.\n \n mode: str, default='clean' \n Options or mode of operation to do on the data. It could \n be ['clean'|'drop']. If ``drop``, it behaves like ``dataframe.drop`` \n of pandas. \n \n Returns\n --------\n DataFrame, array2D or None\n DataFrame cleaned or without the removed index or column labels \n or None if inplace=True or array is data is passed as an array. \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_172cleaner = {"cleaner", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_172cleaner, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_171cleaner}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_172cleaner(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_inplace = 0; PyObject *__pyx_v_labels = 0; PyObject *__pyx_v_func = 0; PyObject *__pyx_v_mode = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("cleaner (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_columns,&__pyx_n_s_inplace,&__pyx_n_s_labels,&__pyx_n_s_func,&__pyx_n_s_mode,0}; PyObject* values[6] = {0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_171cleaner(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_columns, PyObject *__pyx_v_inplace, PyObject *__pyx_v_labels, PyObject *__pyx_v_func, PyObject *__pyx_v_mode, PyObject *__pyx_v_kws) { PyObject *__pyx_v_objtype = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__209) __Pyx_TraceCall("cleaner", __pyx_f[0], 4924, 0, __PYX_ERR(0, 4924, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_data); __Pyx_INCREF(__pyx_v_columns); __Pyx_INCREF(__pyx_v_inplace); __Pyx_INCREF(__pyx_v_mode); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.cleaner", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_objtype); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_columns); __Pyx_XDECREF(__pyx_v_inplace); __Pyx_XDECREF(__pyx_v_mode); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__474 = PyTuple_Pack(8, __pyx_n_s_data, __pyx_n_s_columns, __pyx_n_s_inplace, __pyx_n_s_labels, __pyx_n_s_func, __pyx_n_s_mode, __pyx_n_s_kws_2, __pyx_n_s_objtype); if (unlikely(!__pyx_tuple__474)) __PYX_ERR(0, 4924, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__474); __Pyx_GIVEREF(__pyx_tuple__474); __pyx_codeobj__209 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__474, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_cleaner, 4924, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__209)) __PYX_ERR(0, 4924, __pyx_L1_error) /* … */ __Pyx_TraceLine(4924,0,__PYX_ERR(0, 4924, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4924, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_data, __pyx_kp_s_Union_DataFrame_NDArray) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_kp_s_List_str) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, __pyx_n_s_bool) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_labels, __pyx_kp_s_List_Union_int_str) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_func, __pyx_n_s_F) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_mode, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Union_DataFrame_NDArray_None) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_172cleaner, 0, __pyx_n_s_cleaner, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__209)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4924, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__475); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_cleaner, __pyx_t_5) < 0) __PYX_ERR(0, 4924, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__475 = PyTuple_Pack(5, Py_None, ((PyObject *)Py_False), Py_None, Py_None, ((PyObject*)__pyx_n_u_clean)); if (unlikely(!__pyx_tuple__475)) __PYX_ERR(0, 4924, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__475); __Pyx_GIVEREF(__pyx_tuple__475);
4925: data: Union[DataFrame, NDArray],
+4926: columns: List[str] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4927: inplace: bool = False,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+4928: labels: List[Union[int, str]] = None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+4929: func: _F = None,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_clean))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4924, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4924, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_inplace); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4924, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_labels); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4924, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4924, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_mode); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 4924, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "cleaner") < 0)) __PYX_ERR(0, 4924, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_columns = values[1]; __pyx_v_inplace = values[2]; __pyx_v_labels = values[3]; __pyx_v_func = values[4]; __pyx_v_mode = ((PyObject*)values[5]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("cleaner", 0, 1, 6, __pyx_nargs); __PYX_ERR(0, 4924, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.cleaner", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mode), (&PyUnicode_Type), 0, "mode", 1))) __PYX_ERR(0, 4930, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_171cleaner(__pyx_self, __pyx_v_data, __pyx_v_columns, __pyx_v_inplace, __pyx_v_labels, __pyx_v_func, __pyx_v_mode, __pyx_v_kws);
4930: mode: str = 'clean',
4931: **kws
4932: ) -> Union[DataFrame, NDArray, None]:
4933: """ Sanitize data or columns by dropping specified labels
4934: from rows or columns.
4935:
4936: If data is not a pandas dataframe, should be converted to
4937: dataframe and uses index to drop the labels.
4938:
4939: Parameters
4940: -----------
4941: data: pd.Dataframe or arraylike2D.
4942: Dataframe pandas or Numpy two dimensional arrays. If 2D array is
4943: passed, it should prior be converted to a daframe by default and
4944: drop row index from index parameters
4945:
4946: columns: single label or list-like
4947: Alternative to specifying axis (
4948: labels, axis=1 is equivalent to columns=labels).
4949:
4950: labels: single label or list-like
4951: Index or column labels to drop. A tuple will be used as a single
4952: label and not treated as a list-like.
4953:
4954: func: _F, callable
4955: Universal function used to clean the columns. If performs only when
4956: `mode` is on ``clean`` option.
4957:
4958: inplace: bool, default False
4959: If False, return a copy. Otherwise, do operation
4960: inplace and return None.
4961:
4962: mode: str, default='clean'
4963: Options or mode of operation to do on the data. It could
4964: be ['clean'|'drop']. If ``drop``, it behaves like ``dataframe.drop``
4965: of pandas.
4966:
4967: Returns
4968: --------
4969: DataFrame, array2D or None
4970: DataFrame cleaned or without the removed index or column labels
4971: or None if inplace=True or array is data is passed as an array.
4972:
4973: """
+4974: mode = _validate_name_in(mode , defaults =("drop", 'remove' ),
__Pyx_TraceLine(4974,0,__PYX_ERR(0, 4974, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_validate_name_in); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_mode); __Pyx_GIVEREF(__pyx_v_mode); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_mode)) __PYX_ERR(0, 4974, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_defaults, __pyx_tuple__210) < 0) __PYX_ERR(0, 4974, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_expect_name, __pyx_n_u_drop) < 0) __PYX_ERR(0, 4974, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_4))) __PYX_ERR(0, 4974, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_mode, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0; /* … */ __pyx_tuple__210 = PyTuple_Pack(2, __pyx_n_u_drop, __pyx_n_u_remove); if (unlikely(!__pyx_tuple__210)) __PYX_ERR(0, 4974, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__210); __Pyx_GIVEREF(__pyx_tuple__210);
4975: expect_name ='drop')
+4976: if not mode:
__Pyx_TraceLine(4976,0,__PYX_ERR(0, 4976, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_mode != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_mode) != 0); __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ }
+4977: return sanitize_frame_cols(
__Pyx_TraceLine(4977,0,__PYX_ERR(0, 4977, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_sanitize_frame_cols); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* … */ __Pyx_TraceLine(4978,0,__PYX_ERR(0, 4978, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_data)) __PYX_ERR(0, 4977, __pyx_L1_error); /* … */ __Pyx_TraceLine(4977,0,__PYX_ERR(0, 4977, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4977, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
4978: data,
+4979: inplace = inplace,
__Pyx_TraceLine(4979,0,__PYX_ERR(0, 4979, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4979, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, __pyx_v_inplace) < 0) __PYX_ERR(0, 4979, __pyx_L1_error)
+4980: func = func
__Pyx_TraceLine(4980,0,__PYX_ERR(0, 4980, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_func, __pyx_v_func) < 0) __PYX_ERR(0, 4979, __pyx_L1_error)
4981: )
4982:
+4983: objtype ='ar'
__Pyx_TraceLine(4983,0,__PYX_ERR(0, 4983, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_ar); __pyx_v_objtype = __pyx_n_u_ar;
+4984: if not hasattr (data , '__array__'):
__Pyx_TraceLine(4984,0,__PYX_ERR(0, 4984, __pyx_L1_error)) __pyx_t_6 = __Pyx_HasAttr(__pyx_v_data, __pyx_n_u_array_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 4984, __pyx_L1_error) __pyx_t_5 = (!__pyx_t_6); if (__pyx_t_5) { /* … */ }
+4985: data = np.array (data )
__Pyx_TraceLine(4985,0,__PYX_ERR(0, 4985, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4985, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
4986:
+4987: if hasattr(data , "columns"):
__Pyx_TraceLine(4987,0,__PYX_ERR(0, 4987, __pyx_L1_error)) __pyx_t_5 = __Pyx_HasAttr(__pyx_v_data, __pyx_n_u_columns); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 4987, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+4988: objtype = "pd"
__Pyx_TraceLine(4988,0,__PYX_ERR(0, 4988, __pyx_L1_error)) __Pyx_INCREF(__pyx_n_u_pd); __Pyx_DECREF_SET(__pyx_v_objtype, __pyx_n_u_pd);
4989:
+4990: if objtype =='ar':
__Pyx_TraceLine(4990,0,__PYX_ERR(0, 4990, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_objtype, __pyx_n_u_ar, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 4990, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+4991: data = pd.DataFrame(data )
__Pyx_TraceLine(4991,0,__PYX_ERR(0, 4991, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4991, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
4992: # block inplace to False and
4993: # return numpy ar
+4994: inplace = False
__Pyx_TraceLine(4994,0,__PYX_ERR(0, 4994, __pyx_L1_error)) __Pyx_INCREF(Py_False); __Pyx_DECREF_SET(__pyx_v_inplace, Py_False);
4995: # if isinstance(columns , str):
4996: # columns = str2columns(columns )
+4997: if columns is not None:
__Pyx_TraceLine(4997,0,__PYX_ERR(0, 4997, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_columns != Py_None); if (__pyx_t_5) { /* … */ }
+4998: columns = is_iterable(
__Pyx_TraceLine(4998,0,__PYX_ERR(0, 4998, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(4999,0,__PYX_ERR(0, 4999, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_columns); __Pyx_GIVEREF(__pyx_v_columns); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_columns)) __PYX_ERR(0, 4998, __pyx_L1_error); /* … */ __Pyx_TraceLine(4998,0,__PYX_ERR(0, 4998, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4998, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_4); __pyx_t_4 = 0;
+4999: columns, exclude_string=True ,
__pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 4999, __pyx_L1_error)
+5000: parse_string= True,
__Pyx_TraceLine(5000,0,__PYX_ERR(0, 5000, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_parse_string, Py_True) < 0) __PYX_ERR(0, 4999, __pyx_L1_error)
+5001: transform =True )
__Pyx_TraceLine(5001,0,__PYX_ERR(0, 5001, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 4999, __pyx_L1_error)
5002:
+5003: data = data.drop (labels = labels,
__Pyx_TraceLine(5003,0,__PYX_ERR(0, 5003, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_drop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5003, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5003, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_labels, __pyx_v_labels) < 0) __PYX_ERR(0, 5003, __pyx_L1_error) /* … */ __Pyx_TraceLine(5003,0,__PYX_ERR(0, 5003, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_empty_tuple, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5003, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
+5004: columns = columns,
__Pyx_TraceLine(5004,0,__PYX_ERR(0, 5004, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_v_columns) < 0) __PYX_ERR(0, 5003, __pyx_L1_error)
+5005: inplace =inplace,
__Pyx_TraceLine(5005,0,__PYX_ERR(0, 5005, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, __pyx_v_inplace) < 0) __PYX_ERR(0, 5003, __pyx_L1_error) __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0;
+5006: **kws
__Pyx_TraceLine(5006,0,__PYX_ERR(0, 5006, __pyx_L1_error)) if (__Pyx_MergeKeywords(__pyx_t_3, __pyx_v_kws) < 0) __PYX_ERR(0, 5006, __pyx_L1_error)
5007: )
5008: # re-verify integrity
5009: # for consistency
+5010: data = to_numeric_dtypes(data )
__Pyx_TraceLine(5010,0,__PYX_ERR(0, 5010, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_to_numeric_dtypes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5010, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
+5011: return np.array ( data ) if objtype =='ar' else data
__Pyx_TraceLine(5011,0,__PYX_ERR(0, 5011, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_objtype, __pyx_n_u_ar, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5011, __pyx_L1_error) if (__pyx_t_5) { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_data}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_data); __pyx_t_2 = __pyx_v_data; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
5012:
+5013: def rename_files(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_174rename_files(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_173rename_files, "Rename files in directory.\n\n Parameters \n -----------\n src_files: str, Path-like object \n Source files to rename \n \n dst_files: str of PathLike object \n Destination files renamed. \n \n extension: str, optional \n If a path is given in `src_files`, specifying the `extension` will just \n collect only files with this typical extensions. \n \n basename: str, optional \n If `dst_files` is passed as Path-object, name should be needed \n for a change, otherwise, the number is incremented using the Python \n index counting defined by the parameter ``how=py` \n \n how: str, default='py' \n The way to increment files when `dst_files` is given as a Path object. \n For instance, for a ``name=E_survey`` and ``prefix==True``, the first \n file should be ``E_survey_00`` if ``how='py'`` otherwise it should be \n ``E_survey_01``.\n \n prefix: bool, default=True\n Prefix is used to position the name before the number incrementation. \n If ``False`` and `name` is given, the number is positionning before the \n name. If ``True`` and not `prefix` for a ``name=E_survey``, it should be \n ``00_E_survey`` and ``01_E_survey``. \n\n keep_copy: bool, default=True \n Keep a copy of the source files. \n \n trailer: str, default='_', \n Item used to separate the basename for counter. \n \n sortby: Regex or Callable, \n Key to sort the collection of the items when `src_files` is passed as \n a path-like object. This is usefull to keep order as the origin files \n especially when files includes a specific character. Furthermore \n [int| float |'num'|'digit'] sorted the files according to the\n number included in the filename if exists. \n\n kws: dict \n keyword arguments passed to `os.rename`. \n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_174rename_files = {"rename_files", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_174rename_files, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_173rename_files}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_174rename_files(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_src_files = 0; PyObject *__pyx_v_dst_files = 0; PyObject *__pyx_v_basename = 0; PyObject *__pyx_v_extension = 0; PyObject *__pyx_v_how = 0; PyObject *__pyx_v_prefix = 0; PyObject *__pyx_v_keep_copy = 0; PyObject *__pyx_v_trailer = 0; PyObject *__pyx_v_sortby = 0; PyObject *__pyx_v_kws = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("rename_files (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_src_files,&__pyx_n_s_dst_files,&__pyx_n_s_basename,&__pyx_n_s_extension,&__pyx_n_s_how,&__pyx_n_s_prefix,&__pyx_n_s_keep_copy,&__pyx_n_s_trailer,&__pyx_n_s_sortby,0}; PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_173rename_files(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_src_files, PyObject *__pyx_v_dst_files, PyObject *__pyx_v_basename, PyObject *__pyx_v_extension, PyObject *__pyx_v_how, PyObject *__pyx_v_prefix, PyObject *__pyx_v_keep_copy, PyObject *__pyx_v_trailer, PyObject *__pyx_v_sortby, PyObject *__pyx_v_kws) { PyObject *__pyx_v_dest_dir = NULL; PyObject *__pyx_v_src_path = NULL; PyObject *__pyx_v_ldir = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_ex = NULL; PyObject *__pyx_v_f = NULL; PyObject *__pyx_v_nf = NULL; PyObject *__pyx_9genexpr40__pyx_v_f = NULL; PyObject *__pyx_9genexpr41__pyx_v_f = NULL; PyObject *__pyx_9genexpr42__pyx_v_f = NULL; Py_ssize_t __pyx_9genexpr43__pyx_v_i; Py_ssize_t __pyx_9genexpr44__pyx_v_i; PyObject *__pyx_9genexpr45__pyx_v_f = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__211) __Pyx_TraceCall("rename_files", __pyx_f[0], 5013, 0, __PYX_ERR(0, 5013, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_src_files); __Pyx_INCREF(__pyx_v_dst_files); __Pyx_INCREF(__pyx_v_basename); __Pyx_INCREF(__pyx_v_extension); __Pyx_INCREF(__pyx_v_trailer); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_19); __Pyx_XDECREF(__pyx_t_20); __Pyx_AddTraceback("gofast.tools.coreutils.rename_files", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_dest_dir); __Pyx_XDECREF(__pyx_v_src_path); __Pyx_XDECREF(__pyx_v_ldir); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XDECREF(__pyx_v_f); __Pyx_XDECREF(__pyx_v_nf); __Pyx_XDECREF(__pyx_9genexpr40__pyx_v_f); __Pyx_XDECREF(__pyx_9genexpr41__pyx_v_f); __Pyx_XDECREF(__pyx_9genexpr42__pyx_v_f); __Pyx_XDECREF(__pyx_9genexpr45__pyx_v_f); __Pyx_XDECREF(__pyx_v_src_files); __Pyx_XDECREF(__pyx_v_dst_files); __Pyx_XDECREF(__pyx_v_basename); __Pyx_XDECREF(__pyx_v_extension); __Pyx_XDECREF(__pyx_v_trailer); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__476 = PyTuple_Pack(23, __pyx_n_s_src_files, __pyx_n_s_dst_files, __pyx_n_s_basename, __pyx_n_s_extension, __pyx_n_s_how, __pyx_n_s_prefix, __pyx_n_s_keep_copy, __pyx_n_s_trailer, __pyx_n_s_sortby, __pyx_n_s_kws_2, __pyx_n_s_dest_dir, __pyx_n_s_src_path, __pyx_n_s_ldir, __pyx_n_s__8, __pyx_n_s_ex, __pyx_n_s_f, __pyx_n_s_nf, __pyx_n_s_f, __pyx_n_s_f, __pyx_n_s_f, __pyx_n_s_i, __pyx_n_s_i, __pyx_n_s_f); if (unlikely(!__pyx_tuple__476)) __PYX_ERR(0, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__476); __Pyx_GIVEREF(__pyx_tuple__476); __pyx_codeobj__211 = (PyObject*)__Pyx_PyCode_New(9, 0, 0, 23, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__476, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_rename_files, 5013, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__211)) __PYX_ERR(0, 5013, __pyx_L1_error) /* … */ __Pyx_TraceLine(5013,0,__PYX_ERR(0, 5013, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_src_files, __pyx_kp_s_Union_str_List_str) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dst_files, __pyx_kp_s_Union_str_List_str) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_basename, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_extension, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_how, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_prefix, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_keep_copy, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_trailer, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_sortby, __pyx_kp_s_Union_re_Pattern__F) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_None) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_174rename_files, 0, __pyx_n_s_rename_files, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__211)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__477); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_rename_files, __pyx_t_2) < 0) __PYX_ERR(0, 5013, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__477 = PyTuple_Pack(7, Py_None, Py_None, ((PyObject*)__pyx_n_u_py), ((PyObject *)Py_True), ((PyObject *)Py_True), ((PyObject*)__pyx_n_u__8), Py_None); if (unlikely(!__pyx_tuple__477)) __PYX_ERR(0, 5013, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__477); __Pyx_GIVEREF(__pyx_tuple__477);
5014: src_files: Union[str, List[str]],
5015: dst_files: Union[str, List[str]],
+5016: basename: Optional[str] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+5017: extension: Optional[str] = None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_py)));
5018: how: str = 'py',
+5019: prefix: bool = True,
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+5020: keep_copy: bool = True,
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u__8)));
5021: trailer: str = '_',
+5022: sortby: Union[re.Pattern, _F] = None,
values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_src_files)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dst_files)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("rename_files", 0, 2, 9, 1); __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_basename); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_extension); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_how); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_prefix); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_keep_copy); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_trailer); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sortby); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5013, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "rename_files") < 0)) __PYX_ERR(0, 5013, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_src_files = values[0]; __pyx_v_dst_files = values[1]; __pyx_v_basename = values[2]; __pyx_v_extension = values[3]; __pyx_v_how = ((PyObject*)values[4]); __pyx_v_prefix = values[5]; __pyx_v_keep_copy = values[6]; __pyx_v_trailer = ((PyObject*)values[7]); __pyx_v_sortby = values[8]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("rename_files", 0, 2, 9, __pyx_nargs); __PYX_ERR(0, 5013, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.rename_files", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_how), (&PyUnicode_Type), 0, "how", 1))) __PYX_ERR(0, 5018, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_trailer), (&PyUnicode_Type), 0, "trailer", 1))) __PYX_ERR(0, 5021, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_173rename_files(__pyx_self, __pyx_v_src_files, __pyx_v_dst_files, __pyx_v_basename, __pyx_v_extension, __pyx_v_how, __pyx_v_prefix, __pyx_v_keep_copy, __pyx_v_trailer, __pyx_v_sortby, __pyx_v_kws);
5023: **kws
5024: ) -> None:
5025: """Rename files in directory.
5026:
5027: Parameters
5028: -----------
5029: src_files: str, Path-like object
5030: Source files to rename
5031:
5032: dst_files: str of PathLike object
5033: Destination files renamed.
5034:
5035: extension: str, optional
5036: If a path is given in `src_files`, specifying the `extension` will just
5037: collect only files with this typical extensions.
5038:
5039: basename: str, optional
5040: If `dst_files` is passed as Path-object, name should be needed
5041: for a change, otherwise, the number is incremented using the Python
5042: index counting defined by the parameter ``how=py`
5043:
5044: how: str, default='py'
5045: The way to increment files when `dst_files` is given as a Path object.
5046: For instance, for a ``name=E_survey`` and ``prefix==True``, the first
5047: file should be ``E_survey_00`` if ``how='py'`` otherwise it should be
5048: ``E_survey_01``.
5049:
5050: prefix: bool, default=True
5051: Prefix is used to position the name before the number incrementation.
5052: If ``False`` and `name` is given, the number is positionning before the
5053: name. If ``True`` and not `prefix` for a ``name=E_survey``, it should be
5054: ``00_E_survey`` and ``01_E_survey``.
5055:
5056: keep_copy: bool, default=True
5057: Keep a copy of the source files.
5058:
5059: trailer: str, default='_',
5060: Item used to separate the basename for counter.
5061:
5062: sortby: Regex or Callable,
5063: Key to sort the collection of the items when `src_files` is passed as
5064: a path-like object. This is usefull to keep order as the origin files
5065: especially when files includes a specific character. Furthermore
5066: [int| float |'num'|'digit'] sorted the files according to the
5067: number included in the filename if exists.
5068:
5069: kws: dict
5070: keyword arguments passed to `os.rename`.
5071:
5072: """
+5073: dest_dir =None ; trailer = str(trailer)
__Pyx_TraceLine(5073,0,__PYX_ERR(0, 5073, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_dest_dir = Py_None; __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_trailer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_trailer, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+5074: extension = str(extension).lower()
__Pyx_TraceLine(5074,0,__PYX_ERR(0, 5074, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_extension); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_extension, __pyx_t_1); __pyx_t_1 = 0;
5075:
+5076: if os.path.isfile (src_files ):
__Pyx_TraceLine(5076,0,__PYX_ERR(0, 5076, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isfile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_src_files}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5076, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5076, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ goto __pyx_L3; }
+5077: src_files = [src_files ]
__Pyx_TraceLine(5077,0,__PYX_ERR(0, 5077, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_src_files); __Pyx_GIVEREF(__pyx_v_src_files); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_src_files)) __PYX_ERR(0, 5077, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_src_files, __pyx_t_1); __pyx_t_1 = 0;
5078:
+5079: elif os.path.isdir (src_files):
__Pyx_TraceLine(5079,0,__PYX_ERR(0, 5079, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_isdir); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_src_files}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5079, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5079, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (likely(__pyx_t_5)) { /* … */ goto __pyx_L3; }
+5080: src_path = src_files
__Pyx_TraceLine(5080,0,__PYX_ERR(0, 5080, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_src_files); __pyx_v_src_path = __pyx_v_src_files;
+5081: ldir = os.listdir(src_path)
__Pyx_TraceLine(5081,0,__PYX_ERR(0, 5081, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_listdir); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_src_path}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5081, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_ldir = __pyx_t_1; __pyx_t_1 = 0;
5082:
+5083: src_files = ldir if extension =='none' else [
__Pyx_TraceLine(5083,0,__PYX_ERR(0, 5083, __pyx_L1_error)) __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_v_extension, __pyx_n_u_none, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5083, __pyx_L1_error) if (__pyx_t_5) { __Pyx_INCREF(__pyx_v_ldir); __pyx_t_1 = __pyx_v_ldir; } else { { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5083, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2);
+5084: f for f in ldir if f.endswith (extension) ]
__Pyx_TraceLine(5084,0,__PYX_ERR(0, 5084, __pyx_L6_error)) if (likely(PyList_CheckExact(__pyx_v_ldir)) || PyTuple_CheckExact(__pyx_v_ldir)) { __pyx_t_3 = __pyx_v_ldir; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_ldir); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5084, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5084, __pyx_L6_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5084, __pyx_L6_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5084, __pyx_L6_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5084, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5084, __pyx_L6_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_8); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5084, __pyx_L6_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5084, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5084, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_9genexpr40__pyx_v_f, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr40__pyx_v_f, __pyx_n_s_endswith); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5084, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_extension}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5084, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5084, __pyx_L6_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_11) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_9genexpr40__pyx_v_f))) __PYX_ERR(0, 5083, __pyx_L6_error) } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr40__pyx_v_f); __pyx_9genexpr40__pyx_v_f = 0; goto __pyx_L11_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr40__pyx_v_f); __pyx_9genexpr40__pyx_v_f = 0; goto __pyx_L1_error; __pyx_L11_exit_scope:; } /* exit inner scope */ __pyx_t_1 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_src_files, __pyx_t_1); __pyx_t_1 = 0;
5085:
+5086: if sortby:
__Pyx_TraceLine(5086,0,__PYX_ERR(0, 5086, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_sortby); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5086, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+5087: if sortby in ( int, float, 'num', 'number', 'digit'):
__Pyx_TraceLine(5087,0,__PYX_ERR(0, 5087, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_sortby); __pyx_t_1 = __pyx_v_sortby; __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyInt_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5087, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5087, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_11) { } else { __pyx_t_5 = __pyx_t_11; goto __pyx_L14_bool_binop_done; } __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)(&PyFloat_Type)), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5087, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5087, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_11) { } else { __pyx_t_5 = __pyx_t_11; goto __pyx_L14_bool_binop_done; } __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_num, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5087, __pyx_L1_error) if (!__pyx_t_11) { } else { __pyx_t_5 = __pyx_t_11; goto __pyx_L14_bool_binop_done; } __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_number, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5087, __pyx_L1_error) if (!__pyx_t_11) { } else { __pyx_t_5 = __pyx_t_11; goto __pyx_L14_bool_binop_done; } __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_digit, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5087, __pyx_L1_error) __pyx_t_5 = __pyx_t_11; __pyx_L14_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __pyx_t_5; if (__pyx_t_11) { /* … */ goto __pyx_L13; }
+5088: src_files = sorted(ldir, key=lambda s:int( re.search(
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_12rename_files_lambda16(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_12rename_files_lambda16 = {"lambda16", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_12rename_files_lambda16, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_12rename_files_lambda16(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_s = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda16 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_s_2,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_s_2)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5088, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda16") < 0)) __PYX_ERR(0, 5088, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_s = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda16", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5088, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.rename_files.lambda16", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda16(__pyx_self, __pyx_v_s);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda16(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda16", __pyx_f[0], 5088, 0, __PYX_ERR(0, 5088, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(5088,0,__PYX_ERR(0, 5088, __pyx_L1_error))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_search); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
/* … */
__Pyx_TraceLine(5088,0,__PYX_ERR(0, 5088, __pyx_L1_error))
__pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_1 = __pyx_t_7;
__pyx_t_7 = 0;
} else {
__Pyx_INCREF(__pyx_int_0);
__pyx_t_1 = __pyx_int_0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_AddTraceback("gofast.tools.coreutils.rename_files.lambda16", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(5088,0,__PYX_ERR(0, 5088, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_ldir);
__Pyx_GIVEREF(__pyx_v_ldir);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_ldir)) __PYX_ERR(0, 5088, __pyx_L1_error);
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_12rename_files_lambda16, 0, __pyx_n_s_rename_files_locals_lambda, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_t_3) < 0) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5088, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF_SET(__pyx_v_src_files, __pyx_t_3);
__pyx_t_3 = 0;
+5089: '\d+', s).group()) if re.search('\d+', s) else 0 )
__Pyx_TraceLine(5089,0,__PYX_ERR(0, 5089, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_search); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_kp_u_d_2, __pyx_v_s}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5089, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ __Pyx_TraceLine(5089,0,__PYX_ERR(0, 5089, __pyx_L1_error)) __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_kp_u_d_2, __pyx_v_s}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5088, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_group); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5089, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; }
5090: else:
+5091: src_files = sorted(ldir, key=sortby)
__Pyx_TraceLine(5091,0,__PYX_ERR(0, 5091, __pyx_L1_error)) /*else*/ { __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_ldir); __Pyx_GIVEREF(__pyx_v_ldir); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_ldir)) __PYX_ERR(0, 5091, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_v_sortby) < 0) __PYX_ERR(0, 5091, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5091, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_src_files, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L13:;
5092:
+5093: src_files = [ os.path.join(src_path, f ) for f in src_files ]
__Pyx_TraceLine(5093,0,__PYX_ERR(0, 5093, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_src_files)) || PyTuple_CheckExact(__pyx_v_src_files)) { __pyx_t_2 = __pyx_v_src_files; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_src_files); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5093, __pyx_L21_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5093, __pyx_L21_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5093, __pyx_L21_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5093, __pyx_L21_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5093, __pyx_L21_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5093, __pyx_L21_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_9genexpr41__pyx_v_f, __pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_join); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_v_src_path, __pyx_9genexpr41__pyx_v_f}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 5093, __pyx_L21_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr41__pyx_v_f); __pyx_9genexpr41__pyx_v_f = 0; goto __pyx_L25_exit_scope; __pyx_L21_error:; __Pyx_XDECREF(__pyx_9genexpr41__pyx_v_f); __pyx_9genexpr41__pyx_v_f = 0; goto __pyx_L1_error; __pyx_L25_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_src_files, __pyx_t_1); __pyx_t_1 = 0;
5094: # get only the files
+5095: src_files = [ f for f in src_files if os.path.isfile (f ) ]
__Pyx_TraceLine(5095,0,__PYX_ERR(0, 5095, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_src_files)) || PyTuple_CheckExact(__pyx_v_src_files)) { __pyx_t_2 = __pyx_v_src_files; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_src_files); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5095, __pyx_L28_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5095, __pyx_L28_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5095, __pyx_L28_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5095, __pyx_L28_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5095, __pyx_L28_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5095, __pyx_L28_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_9genexpr42__pyx_v_f, __pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_isfile); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_9genexpr42__pyx_v_f}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5095, __pyx_L28_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_11) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_9genexpr42__pyx_v_f))) __PYX_ERR(0, 5095, __pyx_L28_error) } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr42__pyx_v_f); __pyx_9genexpr42__pyx_v_f = 0; goto __pyx_L33_exit_scope; __pyx_L28_error:; __Pyx_XDECREF(__pyx_9genexpr42__pyx_v_f); __pyx_9genexpr42__pyx_v_f = 0; goto __pyx_L1_error; __pyx_L33_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_src_files, __pyx_t_1); __pyx_t_1 = 0;
5096:
+5097: else : raise FileNotFoundError(f"{src_files!r} not found.")
__Pyx_TraceLine(5097,0,__PYX_ERR(0, 5097, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_FileNotFoundError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5097, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_src_files), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5097, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_kp_u_not_found); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5097, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5097, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 5097, __pyx_L1_error) } __pyx_L3:;
5098:
5099: # Create the directory if it doesn't exist
+5100: if ( dst_files is not None
__Pyx_TraceLine(5100,0,__PYX_ERR(0, 5100, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_dst_files != Py_None); if (__pyx_t_5) { } else { __pyx_t_11 = __pyx_t_5; goto __pyx_L35_bool_binop_done; } /* … */ __Pyx_TraceLine(5100,0,__PYX_ERR(0, 5100, __pyx_L1_error)) if (__pyx_t_11) { /* … */ }
+5101: and not os.path.exists (dst_files)
__Pyx_TraceLine(5101,0,__PYX_ERR(0, 5101, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_exists); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_dst_files}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5101, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = (!__pyx_t_5); __pyx_t_11 = __pyx_t_12; __pyx_L35_bool_binop_done:;
5102: ):
+5103: os.makedirs(dst_files)
__Pyx_TraceLine(5103,0,__PYX_ERR(0, 5103, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_makedirs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_dst_files}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5104:
+5105: if os.path.isdir(dst_files):
__Pyx_TraceLine(5105,0,__PYX_ERR(0, 5105, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_isdir); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_dst_files}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5105, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5105, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_11) { /* … */ }
+5106: dest_dir = dst_files
__Pyx_TraceLine(5106,0,__PYX_ERR(0, 5106, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_dst_files); __Pyx_DECREF_SET(__pyx_v_dest_dir, __pyx_v_dst_files);
5107:
+5108: dst_files = is_iterable(dst_files , exclude_string= True, transform =True )
__Pyx_TraceLine(5108,0,__PYX_ERR(0, 5108, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_dst_files); __Pyx_GIVEREF(__pyx_v_dst_files); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_dst_files)) __PYX_ERR(0, 5108, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 5108, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 5108, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_dst_files, __pyx_t_8); __pyx_t_8 = 0;
5109: # get_extension of the source_files
+5110: _, ex = os.path.splitext (src_files[0])
__Pyx_TraceLine(5110,0,__PYX_ERR(0, 5110, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_splitext); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_src_files, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_1}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) { PyObject* sequence = __pyx_t_8; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5110, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { Py_ssize_t index = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L38_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_2); if (unlikely(!__pyx_t_1)) goto __pyx_L38_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_2), 2) < 0) __PYX_ERR(0, 5110, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L39_unpacking_done; __pyx_L38_unpacking_failed:; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 5110, __pyx_L1_error) __pyx_L39_unpacking_done:; } __pyx_v__ = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_ex = __pyx_t_1; __pyx_t_1 = 0;
5111:
+5112: if dest_dir:
__Pyx_TraceLine(5112,0,__PYX_ERR(0, 5112, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_dest_dir); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5112, __pyx_L1_error) if (__pyx_t_11) { /* … */ }
+5113: if basename is None:
__Pyx_TraceLine(5113,0,__PYX_ERR(0, 5113, __pyx_L1_error)) __pyx_t_11 = (__pyx_v_basename == Py_None); if (__pyx_t_11) { /* … */ }
+5114: warnings.warn(
__Pyx_TraceLine(5114,0,__PYX_ERR(0, 5114, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_u_Missing_basename_for_renaming_fi}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5115: "Missing basename for renaming file. Should use `None` instead.")
+5116: basename =''; trailer =''
__Pyx_TraceLine(5116,0,__PYX_ERR(0, 5116, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__22); __Pyx_DECREF_SET(__pyx_v_basename, __pyx_kp_u__22); __Pyx_INCREF(__pyx_kp_u__22); __Pyx_DECREF_SET(__pyx_v_trailer, __pyx_kp_u__22);
5117:
+5118: basename= str(basename)
__Pyx_TraceLine(5118,0,__PYX_ERR(0, 5118, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Str(__pyx_v_basename); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5118, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF_SET(__pyx_v_basename, __pyx_t_8); __pyx_t_8 = 0;
+5119: if prefix:
__Pyx_TraceLine(5119,0,__PYX_ERR(0, 5119, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_prefix); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5119, __pyx_L1_error) if (__pyx_t_11) { /* … */ goto __pyx_L42; }
+5120: dst_files =[ f"{str(basename)}{trailer}" + (
__Pyx_TraceLine(5120,0,__PYX_ERR(0, 5120, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); /* … */ __Pyx_TraceLine(5120,0,__PYX_ERR(0, 5120, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_v_trailer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5120,0,__PYX_ERR(0, 5120, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_ConcatInPlaceSafe(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+5121: f"{i:03}" if how=='py' else f"{i+1:03}") + f"{ex}"
__Pyx_TraceLine(5121,0,__PYX_ERR(0, 5121, __pyx_L1_error)) __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_v_how, __pyx_n_u_py, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5121, __pyx_L1_error) if (__pyx_t_11) { __pyx_t_2 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_9genexpr43__pyx_v_i, 3, '0', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } else { __pyx_t_2 = __Pyx_PyUnicode_From_Py_ssize_t((__pyx_9genexpr43__pyx_v_i + 1), 3, '0', 'd'); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } /* … */ __Pyx_TraceLine(5121,0,__PYX_ERR(0, 5121, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_ex, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 5120, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_dst_files, __pyx_t_8); __pyx_t_8 = 0;
+5122: for i in range (len(src_files))]
__Pyx_TraceLine(5122,0,__PYX_ERR(0, 5122, __pyx_L1_error)) __pyx_t_6 = PyObject_Length(__pyx_v_src_files); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5122, __pyx_L1_error) __pyx_t_14 = __pyx_t_6; for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_9genexpr43__pyx_v_i = __pyx_t_15;
+5123: elif not prefix:
__Pyx_TraceLine(5123,0,__PYX_ERR(0, 5123, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_prefix); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5123, __pyx_L1_error) __pyx_t_12 = (!__pyx_t_11); if (__pyx_t_12) { /* … */ } __pyx_L42:;
+5124: dst_files =[ (f"{i:03}" if how=='py' else f"{i+1:03}"
__Pyx_TraceLine(5124,0,__PYX_ERR(0, 5124, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); /* … */ __Pyx_TraceLine(5124,0,__PYX_ERR(0, 5124, __pyx_L1_error)) __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_how, __pyx_n_u_py, Py_EQ)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 5124, __pyx_L1_error) if (__pyx_t_12) { __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_9genexpr44__pyx_v_i, 3, '0', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __pyx_t_3 = __Pyx_PyUnicode_From_Py_ssize_t((__pyx_9genexpr44__pyx_v_i + 1), 3, '0', 'd'); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; }
+5125: ) +f"{trailer}{str(basename)}" +f"{ex}"
__Pyx_TraceLine(5125,0,__PYX_ERR(0, 5125, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_basename); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyNumber_Add(__pyx_v_trailer, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlaceSafe(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_v_ex, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 5124, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_dst_files, __pyx_t_8); __pyx_t_8 = 0;
+5126: for i in range (len(src_files))]
__Pyx_TraceLine(5126,0,__PYX_ERR(0, 5126, __pyx_L1_error)) __pyx_t_6 = PyObject_Length(__pyx_v_src_files); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5126, __pyx_L1_error) __pyx_t_14 = __pyx_t_6; for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) { __pyx_9genexpr44__pyx_v_i = __pyx_t_15;
5127:
+5128: dst_files = [os.path.join(dest_dir , f) for f in dst_files ]
__Pyx_TraceLine(5128,0,__PYX_ERR(0, 5128, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_8); if (likely(PyList_CheckExact(__pyx_v_dst_files)) || PyTuple_CheckExact(__pyx_v_dst_files)) { __pyx_t_1 = __pyx_v_dst_files; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_dst_files); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5128, __pyx_L49_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5128, __pyx_L49_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5128, __pyx_L49_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5128, __pyx_L49_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5128, __pyx_L49_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5128, __pyx_L49_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_9genexpr45__pyx_v_f, __pyx_t_2); __pyx_t_2 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_join); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_v_dest_dir, __pyx_9genexpr45__pyx_v_f}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_8, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 5128, __pyx_L49_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr45__pyx_v_f); __pyx_9genexpr45__pyx_v_f = 0; goto __pyx_L53_exit_scope; __pyx_L49_error:; __Pyx_XDECREF(__pyx_9genexpr45__pyx_v_f); __pyx_9genexpr45__pyx_v_f = 0; goto __pyx_L1_error; __pyx_L53_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_dst_files, __pyx_t_8); __pyx_t_8 = 0;
5129:
+5130: for f, nf in zip (src_files , dst_files):
__Pyx_TraceLine(5130,0,__PYX_ERR(0, 5130, __pyx_L1_error)) __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_src_files); __Pyx_GIVEREF(__pyx_v_src_files); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_src_files)) __PYX_ERR(0, 5130, __pyx_L1_error); __Pyx_INCREF(__pyx_v_dst_files); __Pyx_GIVEREF(__pyx_v_dst_files); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_dst_files)) __PYX_ERR(0, 5130, __pyx_L1_error); __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_8 = __pyx_t_1; __Pyx_INCREF(__pyx_t_8); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5130, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_8))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_8); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5130, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5130, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5130, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5130, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_8); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5130, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5130, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_9); if (unlikely(!__pyx_t_2)) goto __pyx_L56_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_13(__pyx_t_9); if (unlikely(!__pyx_t_3)) goto __pyx_L56_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_9), 2) < 0) __PYX_ERR(0, 5130, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L57_unpacking_done; __pyx_L56_unpacking_failed:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 5130, __pyx_L1_error) __pyx_L57_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_f, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_v_nf, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5130,0,__PYX_ERR(0, 5130, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+5131: try:
__Pyx_TraceLine(5131,0,__PYX_ERR(0, 5131, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; goto __pyx_L65_try_end; __pyx_L58_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L60_except_error:; __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); goto __pyx_L1_error; __pyx_L59_exception_handled:; __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_L65_try_end:; }
+5132: if keep_copy : shutil.copy (f, nf , **kws )
__Pyx_TraceLine(5132,0,__PYX_ERR(0, 5132, __pyx_L58_error)) __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_keep_copy); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 5132, __pyx_L58_error) if (__pyx_t_12) { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_shutil); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5132, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5132, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5132, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_f)) __PYX_ERR(0, 5132, __pyx_L58_error); __Pyx_INCREF(__pyx_v_nf); __Pyx_GIVEREF(__pyx_v_nf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_nf)) __PYX_ERR(0, 5132, __pyx_L58_error); __pyx_t_2 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5132, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5132, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L66; }
+5133: else : os.rename (f, nf , **kws )
__Pyx_TraceLine(5133,0,__PYX_ERR(0, 5133, __pyx_L58_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5133, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_rename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5133, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5133, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_f)) __PYX_ERR(0, 5133, __pyx_L58_error); __Pyx_INCREF(__pyx_v_nf); __Pyx_GIVEREF(__pyx_v_nf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_nf)) __PYX_ERR(0, 5133, __pyx_L58_error); __pyx_t_1 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5133, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5133, __pyx_L58_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L66:;
+5134: except FileExistsError:
__Pyx_TraceLine(5134,0,__PYX_ERR(0, 5134, __pyx_L60_except_error)) __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_1, &__pyx_t_9); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_FileExistsError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5134, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_ErrRestore(__pyx_t_3, __pyx_t_1, __pyx_t_9); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_9 = 0; if (__pyx_t_4) { __Pyx_AddTraceback("gofast.tools.coreutils.rename_files", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 5134, __pyx_L60_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3);
+5135: os.remove(nf)
__Pyx_TraceLine(5135,0,__PYX_ERR(0, 5135, __pyx_L60_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_os); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5135, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_remove); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 5135, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_19))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_19); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_19, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_nf}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_19, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5135, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+5136: if keep_copy : shutil.copy (f, nf , **kws )
__Pyx_TraceLine(5136,0,__PYX_ERR(0, 5136, __pyx_L60_except_error)) __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_keep_copy); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 5136, __pyx_L60_except_error) if (__pyx_t_12) { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_shutil); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5136, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 5136, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5136, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f)) __PYX_ERR(0, 5136, __pyx_L60_except_error); __Pyx_INCREF(__pyx_v_nf); __Pyx_GIVEREF(__pyx_v_nf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_nf)) __PYX_ERR(0, 5136, __pyx_L60_except_error); __pyx_t_10 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5136, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_2, __pyx_t_10); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5136, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; goto __pyx_L69; }
+5137: else : os.rename (f, nf , **kws )
__Pyx_TraceLine(5137,0,__PYX_ERR(0, 5137, __pyx_L60_except_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_n_s_os); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5137, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_rename); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5137, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5137, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_INCREF(__pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_v_f)) __PYX_ERR(0, 5137, __pyx_L60_except_error); __Pyx_INCREF(__pyx_v_nf); __Pyx_GIVEREF(__pyx_v_nf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_v_nf)) __PYX_ERR(0, 5137, __pyx_L60_except_error); __pyx_t_2 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5137, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_20, __pyx_t_2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 5137, __pyx_L60_except_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; } __pyx_L69:; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L59_exception_handled; } goto __pyx_L60_except_error;
5138:
5139:
+5140: def get_xy_coordinates (d, as_frame = False, drop_xy = False,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_176get_xy_coordinates(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_175get_xy_coordinates, "Check whether the coordinate values x, y exist in the data.\n \n Parameters \n ------------\n d: Dataframe \n Frame that is expected to contain the longitude/latitude or \n easting/northing coordinates. Note if all types of coordinates are\n included in the data frame, the longitude/latitude takes the \n priority. \n as_frame: bool, default= False, \n Returns the coordinates values if included in the data as a frame rather \n than computing the middle points of the line \n drop_xy: bool, default=False, \n Drop the coordinates in the data and return the data transformed inplace \n \n raise_exception: bool, default=True \n raise error message if data is not a dataframe. If set to ``False``, \n exception is converted to a warning instead. To mute the warning set \n `raise_exception` to ``mute``\n \n verbose: int, default=0 \n Send message whether coordinates are detected. \n \n returns \n --------\n xy, d, xynames: Tuple \n xy : tuple of float ( longitude, latitude) or (easting/northing ) \n if `as_frame` is set to ``True``. \n d: Dataframe transformed (coordinated removed ) or not\n xynames: str, the name of coordinates detected. \n \n Examples \n ----------\n >>> import gofast as gf \n >>> from gofast.tools.coreutils import get_xy_coordinates \n >>> testdata = gf.make_erp ( n_stations =7, seed =42 ).frame \n >>> xy, d, xynames = get_xy_coordinates ( testdata, )\n >>> xy , xynames \n ((110.48627946874444, 26.051952363176344), ('longitude', 'latitude'))\n >>> xy, d, xynames = get_xy_coordinates ( testdata, as_frame =True )\n >>> xy.head(2) \n longitude latitude easting northing\n 0 110.485833 26.051389 448565.380621 2.881476e+06\n 1 110.485982 26.051577 448580.339199 2.881497e+06\n >>> # remove longitude and lat in data \n >>> testdata = testdata.drop"" (columns =['longitude', 'latitude']) \n >>> xy, d, xynames = get_xy_coordinates ( testdata, as_frame =True )\n >>> xy.head(2) \n easting northing\n 0 448565.380621 2.881476e+06\n 1 448580.339199 2.881497e+06\n >>> # note testdata should be transformed inplace when drop_xy is set to True\n >>> xy, d, xynames = get_xy_coordinates ( testdata, drop_xy =True)\n >>> xy, xynames \n ((448610.25612032827, 2881538.4380570543), ('easting', 'northing'))\n >>> d.head(2)\n station resistivity\n 0 0.0 1.0\n 1 20.0 167.5\n >>> testdata.head(2) # coordinates are henceforth been dropped \n station resistivity\n 0 0.0 1.0\n 1 20.0 167.5\n >>> xy, d, xynames = get_xy_coordinates ( testdata, drop_xy =True)\n >>> xy, xynames \n (None, ())\n >>> d.head(2)\n station resistivity\n 0 0.0 1.0\n 1 20.0 167.5\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_176get_xy_coordinates = {"get_xy_coordinates", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_176get_xy_coordinates, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_175get_xy_coordinates}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_176get_xy_coordinates(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_as_frame = 0; PyObject *__pyx_v_drop_xy = 0; PyObject *__pyx_v_raise_exception = 0; PyObject *__pyx_v_verbose = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_xy_coordinates (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_as_frame,&__pyx_n_s_drop_xy,&__pyx_n_s_raise_exception,&__pyx_n_s_verbose,0}; PyObject* values[5] = {0,0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_175get_xy_coordinates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_as_frame, PyObject *__pyx_v_drop_xy, PyObject *__pyx_v_raise_exception, PyObject *__pyx_v_verbose) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates *__pyx_cur_scope; PyObject *__pyx_v_get_value_in = 0; PyObject *__pyx_v_emsg = NULL; PyObject *__pyx_v_name = NULL; PyObject *__pyx_v_tname = NULL; PyObject *__pyx_v_coord_columns = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_xy = NULL; PyObject *__pyx_v_xynames = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__212) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 5140, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("get_xy_coordinates", __pyx_f[0], 5140, 0, __PYX_ERR(0, 5140, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_d = __pyx_v_d; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_d); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_d); __Pyx_INCREF(__pyx_v_raise_exception); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("gofast.tools.coreutils.get_xy_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_get_value_in); __Pyx_XDECREF(__pyx_v_emsg); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_tname); __Pyx_XDECREF(__pyx_v_coord_columns); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_xy); __Pyx_XDECREF(__pyx_v_xynames); __Pyx_XDECREF(__pyx_v_raise_exception); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__478 = PyTuple_Pack(15, __pyx_n_s_d_3, __pyx_n_s_as_frame, __pyx_n_s_drop_xy, __pyx_n_s_raise_exception, __pyx_n_s_verbose, __pyx_n_s_get_value_in, __pyx_n_s_get_value_in, __pyx_n_s_emsg, __pyx_n_s_name_2, __pyx_n_s_tname, __pyx_n_s_coord_columns, __pyx_n_s_x, __pyx_n_s_y_4, __pyx_n_s_xy, __pyx_n_s_xynames); if (unlikely(!__pyx_tuple__478)) __PYX_ERR(0, 5140, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__478); __Pyx_GIVEREF(__pyx_tuple__478); __pyx_codeobj__212 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 15, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__478, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_xy_coordinates, 5140, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__212)) __PYX_ERR(0, 5140, __pyx_L1_error) /* … */ __Pyx_TraceLine(5140,0,__PYX_ERR(0, 5140, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_176get_xy_coordinates, 0, __pyx_n_s_get_xy_coordinates, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__212)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5140, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__479); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_xy_coordinates, __pyx_t_2) < 0) __PYX_ERR(0, 5140, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__479 = PyTuple_Pack(4, ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_True), ((PyObject *)__pyx_int_0)); if (unlikely(!__pyx_tuple__479)) __PYX_ERR(0, 5140, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__479); __Pyx_GIVEREF(__pyx_tuple__479); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates { PyObject_HEAD PyObject *__pyx_v_d; };
+5141: raise_exception = True, verbose=0 ):
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5140, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_as_frame); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5140, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_drop_xy); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5140, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_exception); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5140, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5140, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_xy_coordinates") < 0)) __PYX_ERR(0, 5140, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_d = values[0]; __pyx_v_as_frame = values[1]; __pyx_v_drop_xy = values[2]; __pyx_v_raise_exception = values[3]; __pyx_v_verbose = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_xy_coordinates", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 5140, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_xy_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_175get_xy_coordinates(__pyx_self, __pyx_v_d, __pyx_v_as_frame, __pyx_v_drop_xy, __pyx_v_raise_exception, __pyx_v_verbose);
5142: """Check whether the coordinate values x, y exist in the data.
5143:
5144: Parameters
5145: ------------
5146: d: Dataframe
5147: Frame that is expected to contain the longitude/latitude or
5148: easting/northing coordinates. Note if all types of coordinates are
5149: included in the data frame, the longitude/latitude takes the
5150: priority.
5151: as_frame: bool, default= False,
5152: Returns the coordinates values if included in the data as a frame rather
5153: than computing the middle points of the line
5154: drop_xy: bool, default=False,
5155: Drop the coordinates in the data and return the data transformed inplace
5156:
5157: raise_exception: bool, default=True
5158: raise error message if data is not a dataframe. If set to ``False``,
5159: exception is converted to a warning instead. To mute the warning set
5160: `raise_exception` to ``mute``
5161:
5162: verbose: int, default=0
5163: Send message whether coordinates are detected.
5164:
5165: returns
5166: --------
5167: xy, d, xynames: Tuple
5168: xy : tuple of float ( longitude, latitude) or (easting/northing )
5169: if `as_frame` is set to ``True``.
5170: d: Dataframe transformed (coordinated removed ) or not
5171: xynames: str, the name of coordinates detected.
5172:
5173: Examples
5174: ----------
5175: >>> import gofast as gf
5176: >>> from gofast.tools.coreutils import get_xy_coordinates
5177: >>> testdata = gf.make_erp ( n_stations =7, seed =42 ).frame
5178: >>> xy, d, xynames = get_xy_coordinates ( testdata, )
5179: >>> xy , xynames
5180: ((110.48627946874444, 26.051952363176344), ('longitude', 'latitude'))
5181: >>> xy, d, xynames = get_xy_coordinates ( testdata, as_frame =True )
5182: >>> xy.head(2)
5183: longitude latitude easting northing
5184: 0 110.485833 26.051389 448565.380621 2.881476e+06
5185: 1 110.485982 26.051577 448580.339199 2.881497e+06
5186: >>> # remove longitude and lat in data
5187: >>> testdata = testdata.drop (columns =['longitude', 'latitude'])
5188: >>> xy, d, xynames = get_xy_coordinates ( testdata, as_frame =True )
5189: >>> xy.head(2)
5190: easting northing
5191: 0 448565.380621 2.881476e+06
5192: 1 448580.339199 2.881497e+06
5193: >>> # note testdata should be transformed inplace when drop_xy is set to True
5194: >>> xy, d, xynames = get_xy_coordinates ( testdata, drop_xy =True)
5195: >>> xy, xynames
5196: ((448610.25612032827, 2881538.4380570543), ('easting', 'northing'))
5197: >>> d.head(2)
5198: station resistivity
5199: 0 0.0 1.0
5200: 1 20.0 167.5
5201: >>> testdata.head(2) # coordinates are henceforth been dropped
5202: station resistivity
5203: 0 0.0 1.0
5204: 1 20.0 167.5
5205: >>> xy, d, xynames = get_xy_coordinates ( testdata, drop_xy =True)
5206: >>> xy, xynames
5207: (None, ())
5208: >>> d.head(2)
5209: station resistivity
5210: 0 0.0 1.0
5211: 1 20.0 167.5
5212:
5213: """
5214:
+5215: def get_value_in ( val, col , default):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18get_xy_coordinates_1get_value_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_18get_xy_coordinates_get_value_in, " Get the value in the frame columns if `val` exists in "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_18get_xy_coordinates_1get_value_in = {"get_value_in", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_18get_xy_coordinates_1get_value_in, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_18get_xy_coordinates_get_value_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18get_xy_coordinates_1get_value_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_val = 0; PyObject *__pyx_v_col = 0; PyObject *__pyx_v_default = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_value_in (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_val,&__pyx_n_s_col,&__pyx_n_s_default,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_val)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5215, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_col)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5215, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("get_value_in", 1, 3, 3, 1); __PYX_ERR(0, 5215, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_default)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5215, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("get_value_in", 1, 3, 3, 2); __PYX_ERR(0, 5215, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_value_in") < 0)) __PYX_ERR(0, 5215, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_val = values[0]; __pyx_v_col = values[1]; __pyx_v_default = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_value_in", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 5215, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_xy_coordinates.get_value_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_18get_xy_coordinates_get_value_in(__pyx_self, __pyx_v_val, __pyx_v_col, __pyx_v_default); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18get_xy_coordinates_get_value_in(PyObject *__pyx_self, PyObject *__pyx_v_val, PyObject *__pyx_v_col, PyObject *__pyx_v_default) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in *__pyx_cur_scope; PyObject *__pyx_v_x = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 5215, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates *) __Pyx_CyFunction_GetClosure(__pyx_self); __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope); __Pyx_TraceCall("get_value_in", __pyx_f[0], 5215, 0, __PYX_ERR(0, 5215, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_val = __pyx_v_val; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_val); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_val); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils.get_xy_coordinates.get_value_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_x); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__213 = PyTuple_Pack(4, __pyx_n_s_val, __pyx_n_s_col, __pyx_n_s_default, __pyx_n_s_x); if (unlikely(!__pyx_tuple__213)) __PYX_ERR(0, 5215, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__213); __Pyx_GIVEREF(__pyx_tuple__213); /* … */ __Pyx_TraceLine(5215,0,__PYX_ERR(0, 5215, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_18get_xy_coordinates_1get_value_in, 0, __pyx_n_s_get_xy_coordinates_locals_get_va_2, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__214)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5215, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_get_value_in = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__214 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__213, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_value_in, 5215, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__214)) __PYX_ERR(0, 5215, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in { PyObject_HEAD struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_16_get_xy_coordinates *__pyx_outer_scope; PyObject *__pyx_v_val; };
5216: """ Get the value in the frame columns if `val` exists in """
+5217: x = list( filter ( lambda x: x.find (val)>=0 , col)
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18get_xy_coordinates_12get_value_in_lambda17(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_18get_xy_coordinates_12get_value_in_lambda17 = {"lambda17", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_18get_xy_coordinates_12get_value_in_lambda17, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18get_xy_coordinates_12get_value_in_lambda17(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_x = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda17 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5217, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda17") < 0)) __PYX_ERR(0, 5217, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_x = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda17", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5217, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.get_xy_coordinates.get_value_in.lambda17", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda17(__pyx_self, __pyx_v_x);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda17(PyObject *__pyx_self, PyObject *__pyx_v_x) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_17_get_value_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda17", __pyx_f[0], 5217, 0, __PYX_ERR(0, 5217, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_find); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (unlikely(!__pyx_cur_scope->__pyx_v_val)) { __Pyx_RaiseClosureNameError("val"); __PYX_ERR(0, 5217, __pyx_L1_error) }
__pyx_t_3 = NULL;
__pyx_t_4 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_3)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_4 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_val};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("gofast.tools.coreutils.get_xy_coordinates.get_value_in.lambda17", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(5217,0,__PYX_ERR(0, 5217, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_18get_xy_coordinates_12get_value_in_lambda17, 0, __pyx_n_s_get_xy_coordinates_locals_get_va, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 5217, __pyx_L1_error);
__Pyx_INCREF(__pyx_v_col);
__Pyx_GIVEREF(__pyx_v_col);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_col)) __PYX_ERR(0, 5217, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_filter, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5217, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_x = ((PyObject*)__pyx_t_2);
__pyx_t_2 = 0;
5218: )
+5219: if len(x) !=0:
__Pyx_TraceLine(5219,0,__PYX_ERR(0, 5219, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyList_GET_SIZE(__pyx_v_x); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5219, __pyx_L1_error) __pyx_t_4 = (__pyx_t_3 != 0); if (__pyx_t_4) { /* … */ }
5220: # now rename col
+5221: d.rename (columns = {x[0]: str(default) }, inplace = True )
__Pyx_TraceLine(5221,0,__PYX_ERR(0, 5221, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_d)) { __Pyx_RaiseClosureNameError("d"); __PYX_ERR(0, 5221, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_d, __pyx_n_s_rename); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_x, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_Str(__pyx_v_default); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_5, __pyx_t_6, __pyx_t_7) < 0) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_columns, __pyx_t_5) < 0) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 5221, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5222:
+5223: return d
__Pyx_TraceLine(5223,0,__PYX_ERR(0, 5223, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_d)) { __Pyx_RaiseClosureNameError("d"); __PYX_ERR(0, 5223, __pyx_L1_error) } __Pyx_INCREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_d); __pyx_r = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_d; goto __pyx_L0;
5224:
+5225: if not (
__Pyx_TraceLine(5225,0,__PYX_ERR(0, 5225, __pyx_L1_error)) __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { /* … */ }
+5226: hasattr ( d, 'columns') and hasattr ( d, '__array__')
__Pyx_TraceLine(5226,0,__PYX_ERR(0, 5226, __pyx_L1_error)) __pyx_t_1 = __pyx_cur_scope->__pyx_v_d; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_u_columns); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 5226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_1 = __pyx_cur_scope->__pyx_v_d; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __Pyx_HasAttr(__pyx_t_1, __pyx_n_u_array_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 5226, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:;
5227: ) :
+5228: emsg = ("Expect dataframe containing coordinates longitude/latitude"
__Pyx_TraceLine(5228,0,__PYX_ERR(0, 5228, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_dataframe_containing_coor, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5228, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_emsg = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+5229: f" or easting/northing. Got {type (d).__name__!r}")
__Pyx_TraceLine(5229,0,__PYX_ERR(0, 5229, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_cur_scope->__pyx_v_d)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_1), __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5230:
+5231: raise_exception = str(raise_exception).lower().strip()
__Pyx_TraceLine(5231,0,__PYX_ERR(0, 5231, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Str(__pyx_v_raise_exception); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_lower); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strip); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5231, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF_SET(__pyx_v_raise_exception, __pyx_t_1); __pyx_t_1 = 0;
+5232: if raise_exception=='true':
__Pyx_TraceLine(5232,0,__PYX_ERR(0, 5232, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_raise_exception, __pyx_n_u_true, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5232, __pyx_L1_error) if (unlikely(__pyx_t_3)) { /* … */ }
+5233: raise TypeError ( emsg )
__Pyx_TraceLine(5233,0,__PYX_ERR(0, 5233, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_v_emsg); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 5233, __pyx_L1_error)
5234:
+5235: if raise_exception not in ('mute', 'silence'):
__Pyx_TraceLine(5235,0,__PYX_ERR(0, 5235, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_raise_exception); __pyx_t_1 = __pyx_v_raise_exception; __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_mute, Py_NE)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 5235, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_3 = __pyx_t_2; goto __pyx_L8_bool_binop_done; } __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_silence, Py_NE)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 5235, __pyx_L1_error) __pyx_t_3 = __pyx_t_2; __pyx_L8_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = __pyx_t_3; if (__pyx_t_2) { /* … */ }
+5236: warnings.warn( emsg )
__Pyx_TraceLine(5236,0,__PYX_ERR(0, 5236, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_warnings); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_emsg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5237:
+5238: return d
__Pyx_TraceLine(5238,0,__PYX_ERR(0, 5238, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_d); __pyx_r = __pyx_cur_scope->__pyx_v_d; goto __pyx_L0;
5239:
5240: # check whether coordinates exists in the data columns
+5241: for name, tname in zip ( ('lat', 'lon', 'east', 'north'),
__pyx_tuple__215 = PyTuple_Pack(4, __pyx_n_u_lat, __pyx_n_u_lon, __pyx_n_u_east, __pyx_n_u_north); if (unlikely(!__pyx_tuple__215)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__215); __Pyx_GIVEREF(__pyx_tuple__215); /* … */ __Pyx_TraceLine(5241,0,__PYX_ERR(0, 5241, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_tuple__217, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5241, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5241, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 5241, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5241, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 5241, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5241, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5241, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_6 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_6)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L12_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 5241, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L13_unpacking_done; __pyx_L12_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 5241, __pyx_L1_error) __pyx_L13_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_tname, __pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(5241,0,__PYX_ERR(0, 5241, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_tuple__217 = PyTuple_Pack(2, __pyx_tuple__215, __pyx_tuple__216); if (unlikely(!__pyx_tuple__217)) __PYX_ERR(0, 5241, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__217); __Pyx_GIVEREF(__pyx_tuple__217);
+5242: ( 'latitude', 'longitude', 'easting', 'northing')
__pyx_tuple__216 = PyTuple_Pack(4, __pyx_n_u_latitude, __pyx_n_u_longitude, __pyx_n_u_easting, __pyx_n_u_northing); if (unlikely(!__pyx_tuple__216)) __PYX_ERR(0, 5242, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__216); __Pyx_GIVEREF(__pyx_tuple__216);
5243: ) :
+5244: d = get_value_in(name, col = d.columns , default = tname )
__Pyx_TraceLine(5244,0,__PYX_ERR(0, 5244, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_name)) __PYX_ERR(0, 5244, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_d, __pyx_n_s_columns); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_col, __pyx_t_6) < 0) __PYX_ERR(0, 5244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_default, __pyx_v_tname) < 0) __PYX_ERR(0, 5244, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_get_value_in, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_d); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_d, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0;
5245:
5246: # get the exist coodinates
+5247: coord_columns = []
__Pyx_TraceLine(5247,0,__PYX_ERR(0, 5247, __pyx_L1_error)) __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5247, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_v_coord_columns = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0;
+5248: for x, y in zip ( ( 'longitude', 'easting' ), ( 'latitude', 'northing')):
__pyx_tuple__218 = PyTuple_Pack(2, __pyx_n_u_longitude, __pyx_n_u_easting); if (unlikely(!__pyx_tuple__218)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__218); __Pyx_GIVEREF(__pyx_tuple__218); __pyx_tuple__219 = PyTuple_Pack(2, __pyx_n_u_latitude, __pyx_n_u_northing); if (unlikely(!__pyx_tuple__219)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__219); __Pyx_GIVEREF(__pyx_tuple__219); /* … */ __Pyx_TraceLine(5248,0,__PYX_ERR(0, 5248, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_zip, __pyx_tuple__220, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { __pyx_t_6 = __pyx_t_4; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5248, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_6))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5248, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 5248, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5248, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 5248, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5248, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5248, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L17_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) __PYX_ERR(0, 5248, __pyx_L1_error) __pyx_t_11 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L18_unpacking_done; __pyx_L17_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 5248, __pyx_L1_error) __pyx_L18_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v_x, __pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF_SET(__pyx_v_y, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(5248,0,__PYX_ERR(0, 5248, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_tuple__220 = PyTuple_Pack(2, __pyx_tuple__218, __pyx_tuple__219); if (unlikely(!__pyx_tuple__220)) __PYX_ERR(0, 5248, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__220); __Pyx_GIVEREF(__pyx_tuple__220);
+5249: if ( x in d.columns and y in d.columns ):
__Pyx_TraceLine(5249,0,__PYX_ERR(0, 5249, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_d, __pyx_n_s_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_x, __pyx_t_4, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L20_bool_binop_done; } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_d, __pyx_n_s_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5249, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_y, __pyx_t_4, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5249, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __pyx_t_3; __pyx_L20_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+5250: coord_columns.extend ( [x, y] )
__Pyx_TraceLine(5250,0,__PYX_ERR(0, 5250, __pyx_L1_error)) __pyx_t_12 = __Pyx_ListComp_Append(__pyx_v_coord_columns, __pyx_v_x); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 5250, __pyx_L1_error) __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_coord_columns, __pyx_v_y); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 5250, __pyx_L1_error) (void)((__pyx_t_12 | __pyx_t_13));
5251:
+5252: xy = d[ coord_columns] if len(coord_columns)!=0 else None
__Pyx_TraceLine(5252,0,__PYX_ERR(0, 5252, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyList_GET_SIZE(__pyx_v_coord_columns); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5252, __pyx_L1_error) __pyx_t_2 = (__pyx_t_8 != 0); if (__pyx_t_2) { __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_d, __pyx_v_coord_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __pyx_t_4; __pyx_t_4 = 0; } else { __Pyx_INCREF(Py_None); __pyx_t_6 = Py_None; } __pyx_v_xy = __pyx_t_6; __pyx_t_6 = 0;
5253:
+5254: if ( not as_frame
__Pyx_TraceLine(5254,0,__PYX_ERR(0, 5254, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_as_frame); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5254, __pyx_L1_error) __pyx_t_14 = (!__pyx_t_3); if (__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L24_bool_binop_done; } /* … */ __Pyx_TraceLine(5254,0,__PYX_ERR(0, 5254, __pyx_L1_error)) if (__pyx_t_2) { /* … */ }
+5255: and xy is not None ) :
__Pyx_TraceLine(5255,0,__PYX_ERR(0, 5255, __pyx_L1_error)) __pyx_t_14 = (__pyx_v_xy != Py_None); __pyx_t_2 = __pyx_t_14; __pyx_L24_bool_binop_done:;
5256: # take the middle of the line and if both types of
5257: # coordinates are supplied , take longitude and latitude
5258: # and drop easting and northing
+5259: xy = tuple ( np.nanmean ( np.array ( xy ) , axis =0 )) [:2]
__Pyx_TraceLine(5259,0,__PYX_ERR(0, 5259, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_nanmean); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_xy}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6)) __PYX_ERR(0, 5259, __pyx_L1_error); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_axis, __pyx_int_0) < 0) __PYX_ERR(0, 5259, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyTuple_GetSlice(__pyx_t_6, 0, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_xy, __pyx_t_1); __pyx_t_1 = 0;
5260:
+5261: xynames = tuple ( coord_columns)[:2]
__Pyx_TraceLine(5261,0,__PYX_ERR(0, 5261, __pyx_L1_error)) __pyx_t_1 = PyList_AsTuple(__pyx_v_coord_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyTuple_GetSlice(__pyx_t_1, 0, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5261, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_xynames = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0;
+5262: if (
__Pyx_TraceLine(5262,0,__PYX_ERR(0, 5262, __pyx_L1_error)) if (__pyx_t_2) { /* … */ }
+5263: drop_xy and len( coord_columns) !=0
__Pyx_TraceLine(5263,0,__PYX_ERR(0, 5263, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_drop_xy); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 5263, __pyx_L1_error) if (__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L27_bool_binop_done; } __pyx_t_8 = __Pyx_PyList_GET_SIZE(__pyx_v_coord_columns); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5263, __pyx_L1_error) __pyx_t_14 = (__pyx_t_8 != 0); __pyx_t_2 = __pyx_t_14; __pyx_L27_bool_binop_done:;
5264: ):
5265: # modifie the data inplace
+5266: d.drop ( columns=coord_columns, inplace = True )
__Pyx_TraceLine(5266,0,__PYX_ERR(0, 5266, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_d, __pyx_n_s_drop); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_columns, __pyx_v_coord_columns) < 0) __PYX_ERR(0, 5266, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 5266, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5266, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5267:
+5268: if verbose:
__Pyx_TraceLine(5268,0,__PYX_ERR(0, 5268, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_verbose); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 5268, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+5269: print("###", "No" if len(xynames)==0 else (
__Pyx_TraceLine(5269,0,__PYX_ERR(0, 5269, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyTuple_GET_SIZE(__pyx_v_xynames); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5269, __pyx_L1_error) __pyx_t_2 = (__pyx_t_8 == 0); if (__pyx_t_2) { __Pyx_INCREF(__pyx_n_u_No_2); __pyx_t_5 = __pyx_n_u_No_2; } else { /* … */ __Pyx_TraceLine(5269,0,__PYX_ERR(0, 5269, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_u__221); __Pyx_GIVEREF(__pyx_kp_u__221); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__221)) __PYX_ERR(0, 5269, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5)) __PYX_ERR(0, 5269, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u_coordinates_found); __Pyx_GIVEREF(__pyx_kp_u_coordinates_found); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_coordinates_found)) __PYX_ERR(0, 5269, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_print, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+5270: tuple (xy.columns) if as_frame else xy), "coordinates found.")
__Pyx_TraceLine(5270,0,__PYX_ERR(0, 5270, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_as_frame); if (unlikely((__pyx_t_14 < 0))) __PYX_ERR(0, 5270, __pyx_L1_error) if (__pyx_t_14) { __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_xy, __pyx_n_s_columns); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else { __Pyx_INCREF(__pyx_v_xy); __pyx_t_1 = __pyx_v_xy; } __pyx_t_5 = __pyx_t_1; __pyx_t_1 = 0; }
5271:
+5272: return xy , d , xynames
__Pyx_TraceLine(5272,0,__PYX_ERR(0, 5272, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5272, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_xy); __Pyx_GIVEREF(__pyx_v_xy); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_xy)) __PYX_ERR(0, 5272, __pyx_L1_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_d); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_cur_scope->__pyx_v_d)) __PYX_ERR(0, 5272, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xynames); __Pyx_GIVEREF(__pyx_v_xynames); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_xynames)) __PYX_ERR(0, 5272, __pyx_L1_error); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
5273:
5274:
+5275: def pair_data(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_328__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 5275, 0, __PYX_ERR(0, 5275, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
/* … */
__Pyx_TraceLine(5275,0,__PYX_ERR(0, 5275, __pyx_L1_error))
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_decimals, __Pyx_CyFunction_Defaults(__pyx_defaults11, __pyx_self)->__pyx_arg_decimals) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
/* … */
__Pyx_TraceLine(5275,0,__PYX_ERR(0, 5275, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, Py_None)) __PYX_ERR(0, 5275, __pyx_L1_error);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1)) __PYX_ERR(0, 5275, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_178pair_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_177pair_data, " Find indentical object in all data and concatenate them using merge \n intersection (`cross`) strategy.\n \n Parameters \n ---------- \n d: List of DataFrames \n List of pandas DataFrames \n on: str, label or list \n Column or index level names to join on. These must be found in \n all DataFrames. If `on` is ``None`` and not merging on indexes then \n a concatenation along columns axis is performed in all DataFrames. \n Note that `on` works with `parse_on` if its argument is a list of \n columns names passed into single litteral string. For instance:: \n \n on ='longitude latitude' --[parse_on=True]-> ['longitude' , 'latitude'] \n \n parse_on: bool, default=False \n Parse `on` arguments if given as string and return_iterable objects. \n \n mode: str, default='strict' \n Mode to the data. Can be ['soft'|'strict']. In ``strict`` mode, all the \n data passed must be a DataFrame, otherwise an error raises. in ``soft``\n mode, ignore the non-DataFrame. Note that any other values should be \n in ``strict`` mode. \n \n coerce: bool, default=False \n Truncate all DataFrame size to much the shorter one before performing \n the ``merge``. \n \n force: bool, default=False, \n Force `on` items to be in the all DataFrames, This could be possible \n at least, `on` items should be in one DataFrame. If missing in all \n data, an error occurs. \n \n decimals: int, default=5 \n Decimal is used for comparison between numeric labels in `on` columns \n items. If set, it rounds values of `on` items in all data before \n performing the merge. \n \n raise_warn: bool, default=False \n Warn user to concatenate data along column axis if `on` is ``None``. \n\n Returns \n --------\n data: DataFrames \n A DataFrame of the merged objects.\n \n Examples \n ----------""\n >>> import gofast as gf \n >>> from gofast.tools.coreutils import pair_data \n >>> data = gf.make_erp (seed =42 , n_stations =12, as_frame =True ) \n >>> table1 = gf.DCProfiling ().fit(data).summary()\n >>> table1 \n dipole longitude latitude ... shape type sfi\n line1 10 110.486111 26.05174 ... C EC 1.141844\n >>> data_no_xy = gf.make_ves ( seed=0 , as_frame =True) \n >>> data_no_xy.head(2) \n AB MN resistivity\n 0 1.0 0.4 448.860148\n 1 2.0 0.4 449.060335\n >>> data_xy = gf.make_ves ( seed =0 , as_frame =True , add_xy =True ) \n >>> data_xy.head(2) \n AB MN resistivity longitude latitude\n 0 1.0 0.4 448.860148 109.332931 28.41193\n 1 2.0 0.4 449.060335 109.332931 28.41193\n >>> table = gf.methods.VerticalSounding (\n xycoords = (110.486111, 26.05174)).fit(data_no_xy).summary() \n >>> table.table_\n AB MN arrangememt ... nareas longitude latitude\n area ... \n None 200.0 20.0 schlumberger ... 1 110.486111 26.05174\n >>> pair_data (table1, table.table_, ) \n dipole longitude latitude ... nareas longitude latitude\n line1 10.0 110.486111 26.05174 ... NaN NaN NaN\n None NaN NaN NaN ... 1.0 110.486111 26.05174\n >>> pair_data (table1, table.table_, on =['longitude', 'latitude'] ) \n Empty DataFrame \n >>> # comments: Empty dataframe appears because, decimal is too large \n >>> # then it considers values longitude and latitude differents \n >>> pair_data (table1, table.table_, on =['longitude', 'latitude'], decimals =5 ) \n dipole longitude latitude ... max_depth ohmic_area nareas\n 0 10 110.48611 26.05174 ... 109.0 690.063003 1\n >>> # Now is able to find existing dataframe with identical closer coordinates."" \n \n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_178pair_data = {"pair_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_178pair_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_177pair_data};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_178pair_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_on = 0;
PyObject *__pyx_v_parse_on = 0;
PyObject *__pyx_v_mode = 0;
PyObject *__pyx_v_coerce = 0;
PyObject *__pyx_v_force = 0;
PyObject *__pyx_v_decimals = 0;
PyObject *__pyx_v_raise_warn = 0;
PyObject *__pyx_v_d = 0;
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("pair_data (wrapper)", 0);
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__Pyx_INCREF(__pyx_args);
__pyx_v_d = __pyx_args;
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_on,&__pyx_n_s_parse_on,&__pyx_n_s_mode,&__pyx_n_s_coerce,&__pyx_n_s_force,&__pyx_n_s_decimals,&__pyx_n_s_raise_warn,0};
PyObject* values[7] = {0,0,0,0,0,0,0};
__pyx_defaults11 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults11, __pyx_self);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_d);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_177pair_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_on, PyObject *__pyx_v_parse_on, PyObject *__pyx_v_mode, PyObject *__pyx_v_coerce, PyObject *__pyx_v_force, PyObject *__pyx_v_decimals, PyObject *__pyx_v_raise_warn, PyObject *__pyx_v_d) {
PyObject *__pyx_v__is_numeric_dtype = NULL;
PyObject *__pyx_v_is_same = NULL;
PyObject *__pyx_v_types = NULL;
PyObject *__pyx_v_same_len = NULL;
PyObject *__pyx_v_min_index = NULL;
PyObject *__pyx_v_feature_exist = NULL;
PyObject *__pyx_v_dtems = NULL;
PyObject *__pyx_v_repl_twd = NULL;
PyObject *__pyx_v_o = NULL;
PyObject *__pyx_v_a = NULL;
PyObject *__pyx_v_is_num = NULL;
PyObject *__pyx_v_d_ = NULL;
PyObject *__pyx_v_data = NULL;
PyObject *__pyx_v_ii = NULL;
PyObject *__pyx_9genexpr46__pyx_v_o = NULL;
PyObject *__pyx_9genexpr47__pyx_v_o = NULL;
PyObject *__pyx_9genexpr48__pyx_v_o = NULL;
PyObject *__pyx_9genexpr49__pyx_v_o = NULL;
PyObject *__pyx_9genexpr50__pyx_v_o = NULL;
PyObject *__pyx_9genexpr51__pyx_v_o = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__222)
__Pyx_TraceCall("pair_data", __pyx_f[0], 5275, 0, __PYX_ERR(0, 5275, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_on);
__Pyx_INCREF(__pyx_v_decimals);
__Pyx_INCREF(__pyx_v_d);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_13);
__Pyx_XDECREF(__pyx_t_14);
__Pyx_XDECREF(__pyx_t_18);
__Pyx_XDECREF(__pyx_t_20);
__Pyx_AddTraceback("gofast.tools.coreutils.pair_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_d);
__Pyx_XDECREF(__pyx_v__is_numeric_dtype);
__Pyx_XDECREF(__pyx_v_is_same);
__Pyx_XDECREF(__pyx_v_types);
__Pyx_XDECREF(__pyx_v_same_len);
__Pyx_XDECREF(__pyx_v_min_index);
__Pyx_XDECREF(__pyx_v_feature_exist);
__Pyx_XDECREF(__pyx_v_dtems);
__Pyx_XDECREF(__pyx_v_repl_twd);
__Pyx_XDECREF(__pyx_v_o);
__Pyx_XDECREF(__pyx_v_a);
__Pyx_XDECREF(__pyx_v_is_num);
__Pyx_XDECREF(__pyx_v_d_);
__Pyx_XDECREF(__pyx_v_data);
__Pyx_XDECREF(__pyx_v_ii);
__Pyx_XDECREF(__pyx_9genexpr46__pyx_v_o);
__Pyx_XDECREF(__pyx_9genexpr47__pyx_v_o);
__Pyx_XDECREF(__pyx_9genexpr48__pyx_v_o);
__Pyx_XDECREF(__pyx_9genexpr49__pyx_v_o);
__Pyx_XDECREF(__pyx_9genexpr50__pyx_v_o);
__Pyx_XDECREF(__pyx_9genexpr51__pyx_v_o);
__Pyx_XDECREF(__pyx_v_on);
__Pyx_XDECREF(__pyx_v_decimals);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__480 = PyTuple_Pack(28, __pyx_n_s_on, __pyx_n_s_parse_on, __pyx_n_s_mode, __pyx_n_s_coerce, __pyx_n_s_force, __pyx_n_s_decimals, __pyx_n_s_raise_warn, __pyx_n_s_d_3, __pyx_n_s_is_numeric_dtype, __pyx_n_s_is_same, __pyx_n_s_types, __pyx_n_s_same_len, __pyx_n_s_min_index, __pyx_n_s_feature_exist, __pyx_n_s_dtems, __pyx_n_s_repl_twd, __pyx_n_s_o, __pyx_n_s_a, __pyx_n_s_is_num, __pyx_n_s_d_5, __pyx_n_s_data, __pyx_n_s_ii, __pyx_n_s_o, __pyx_n_s_o, __pyx_n_s_o, __pyx_n_s_o, __pyx_n_s_o, __pyx_n_s_o); if (unlikely(!__pyx_tuple__480)) __PYX_ERR(0, 5275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__480);
__Pyx_GIVEREF(__pyx_tuple__480);
/* … */
__Pyx_TraceLine(5275,0,__PYX_ERR(0, 5275, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_on, __pyx_kp_s_Union_str_List_str) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parse_on, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_mode, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_coerce, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_force, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_decimals, __pyx_n_s_int) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_raise_warn, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_d_3, __pyx_kp_s_Union_DataFrame_List_DataFrame) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
__pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_178pair_data, 0, __pyx_n_s_pair_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__222)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_5, sizeof(__pyx_defaults11), 1)) __PYX_ERR(0, 5275, __pyx_L1_error)
__pyx_codeobj__222 = (PyObject*)__Pyx_PyCode_New(0, 0, 7, 28, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__480, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_pair_data, 5275, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__222)) __PYX_ERR(0, 5275, __pyx_L1_error)
5276: *d: Union[DataFrame, List[DataFrame]],
+5277: on: Union[str, List[str]] = None,
__Pyx_TraceLine(5277,0,__PYX_ERR(0, 5277, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_on, Py_None) < 0) __PYX_ERR(0, 5275, __pyx_L1_error) /* … */ values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None)); values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)((PyObject*)__pyx_n_u_strict))); values[3] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[4] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[5] = __Pyx_Arg_NewRef_VARARGS(__pyx_dynamic_args->__pyx_arg_decimals); values[6] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args > 0 && likely(kw_args <= 7)) { Py_ssize_t index; for (index = 0; index < 7 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5275, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "pair_data") < 0)) __PYX_ERR(0, 5275, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_on = values[0]; __pyx_v_parse_on = values[1]; __pyx_v_mode = ((PyObject*)values[2]); __pyx_v_coerce = values[3]; __pyx_v_force = values[4]; __pyx_v_decimals = ((PyObject*)values[5]); __pyx_v_raise_warn = values[6]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("pair_data", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 5275, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_d); __pyx_v_d = 0; __Pyx_AddTraceback("gofast.tools.coreutils.pair_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mode), (&PyUnicode_Type), 0, "mode", 1))) __PYX_ERR(0, 5279, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_decimals), (&PyInt_Type), 0, "decimals", 1))) __PYX_ERR(0, 5282, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_177pair_data(__pyx_self, __pyx_v_on, __pyx_v_parse_on, __pyx_v_mode, __pyx_v_coerce, __pyx_v_force, __pyx_v_decimals, __pyx_v_raise_warn, __pyx_v_d);
+5278: parse_on: bool = False,
__Pyx_TraceLine(5278,0,__PYX_ERR(0, 5278, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_parse_on, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 5275, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_mode, ((PyObject*)__pyx_n_u_strict)) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
5279: mode: str = 'strict',
+5280: coerce: bool = False,
__Pyx_TraceLine(5280,0,__PYX_ERR(0, 5280, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_coerce, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
+5281: force: bool = False,
__Pyx_TraceLine(5281,0,__PYX_ERR(0, 5281, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_force, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
+5282: decimals: int = 7,
__Pyx_TraceLine(5282,0,__PYX_ERR(0, 5282, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_7)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_7))) __PYX_ERR(0, 5282, __pyx_L1_error) __Pyx_INCREF(__pyx_int_7); __Pyx_CyFunction_Defaults(__pyx_defaults11, __pyx_t_5)->__pyx_arg_decimals = ((PyObject*)__pyx_int_7); __Pyx_GIVEREF(__pyx_int_7); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_5, __pyx_pf_6gofast_5tools_9coreutils_328__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_pair_data, __pyx_t_5) < 0) __PYX_ERR(0, 5275, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+5283: raise_warn: bool = True
__Pyx_TraceLine(5283,0,__PYX_ERR(0, 5283, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_raise_warn, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 5275, __pyx_L1_error)
5284: ) -> DataFrame:
5285: """ Find indentical object in all data and concatenate them using merge
5286: intersection (`cross`) strategy.
5287:
5288: Parameters
5289: ----------
5290: d: List of DataFrames
5291: List of pandas DataFrames
5292: on: str, label or list
5293: Column or index level names to join on. These must be found in
5294: all DataFrames. If `on` is ``None`` and not merging on indexes then
5295: a concatenation along columns axis is performed in all DataFrames.
5296: Note that `on` works with `parse_on` if its argument is a list of
5297: columns names passed into single litteral string. For instance::
5298:
5299: on ='longitude latitude' --[parse_on=True]-> ['longitude' , 'latitude']
5300:
5301: parse_on: bool, default=False
5302: Parse `on` arguments if given as string and return_iterable objects.
5303:
5304: mode: str, default='strict'
5305: Mode to the data. Can be ['soft'|'strict']. In ``strict`` mode, all the
5306: data passed must be a DataFrame, otherwise an error raises. in ``soft``
5307: mode, ignore the non-DataFrame. Note that any other values should be
5308: in ``strict`` mode.
5309:
5310: coerce: bool, default=False
5311: Truncate all DataFrame size to much the shorter one before performing
5312: the ``merge``.
5313:
5314: force: bool, default=False,
5315: Force `on` items to be in the all DataFrames, This could be possible
5316: at least, `on` items should be in one DataFrame. If missing in all
5317: data, an error occurs.
5318:
5319: decimals: int, default=5
5320: Decimal is used for comparison between numeric labels in `on` columns
5321: items. If set, it rounds values of `on` items in all data before
5322: performing the merge.
5323:
5324: raise_warn: bool, default=False
5325: Warn user to concatenate data along column axis if `on` is ``None``.
5326:
5327: Returns
5328: --------
5329: data: DataFrames
5330: A DataFrame of the merged objects.
5331:
5332: Examples
5333: ----------
5334: >>> import gofast as gf
5335: >>> from gofast.tools.coreutils import pair_data
5336: >>> data = gf.make_erp (seed =42 , n_stations =12, as_frame =True )
5337: >>> table1 = gf.DCProfiling ().fit(data).summary()
5338: >>> table1
5339: dipole longitude latitude ... shape type sfi
5340: line1 10 110.486111 26.05174 ... C EC 1.141844
5341: >>> data_no_xy = gf.make_ves ( seed=0 , as_frame =True)
5342: >>> data_no_xy.head(2)
5343: AB MN resistivity
5344: 0 1.0 0.4 448.860148
5345: 1 2.0 0.4 449.060335
5346: >>> data_xy = gf.make_ves ( seed =0 , as_frame =True , add_xy =True )
5347: >>> data_xy.head(2)
5348: AB MN resistivity longitude latitude
5349: 0 1.0 0.4 448.860148 109.332931 28.41193
5350: 1 2.0 0.4 449.060335 109.332931 28.41193
5351: >>> table = gf.methods.VerticalSounding (
5352: xycoords = (110.486111, 26.05174)).fit(data_no_xy).summary()
5353: >>> table.table_
5354: AB MN arrangememt ... nareas longitude latitude
5355: area ...
5356: None 200.0 20.0 schlumberger ... 1 110.486111 26.05174
5357: >>> pair_data (table1, table.table_, )
5358: dipole longitude latitude ... nareas longitude latitude
5359: line1 10.0 110.486111 26.05174 ... NaN NaN NaN
5360: None NaN NaN NaN ... 1.0 110.486111 26.05174
5361: >>> pair_data (table1, table.table_, on =['longitude', 'latitude'] )
5362: Empty DataFrame
5363: >>> # comments: Empty dataframe appears because, decimal is too large
5364: >>> # then it considers values longitude and latitude differents
5365: >>> pair_data (table1, table.table_, on =['longitude', 'latitude'], decimals =5 )
5366: dipole longitude latitude ... max_depth ohmic_area nareas
5367: 0 10 110.48611 26.05174 ... 109.0 690.063003 1
5368: >>> # Now is able to find existing dataframe with identical closer coordinates.
5369:
5370: """
+5371: from .validator import _is_numeric_dtype
__Pyx_TraceLine(5371,0,__PYX_ERR(0, 5371, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_is_numeric_dtype); __Pyx_GIVEREF(__pyx_n_s_is_numeric_dtype); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_is_numeric_dtype)) __PYX_ERR(0, 5371, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_validator, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_is_numeric_dtype); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5371, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v__is_numeric_dtype = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5372:
+5373: if str(mode).lower()=='soft':
__Pyx_TraceLine(5373,0,__PYX_ERR(0, 5373, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_mode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_soft, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5373, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_5) { /* … */ }
+5374: d = [ o for o in d if hasattr (o, '__array__') and hasattr (o, 'columns') ]
__Pyx_TraceLine(5374,0,__PYX_ERR(0, 5374, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5374, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_3 = __pyx_v_d; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5374, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5374, __pyx_L6_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5374, __pyx_L6_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5374, __pyx_L6_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5374, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5374, __pyx_L6_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5374, __pyx_L6_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5374, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5374, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr46__pyx_v_o, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = __Pyx_HasAttr(__pyx_9genexpr46__pyx_v_o, __pyx_n_u_array_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 5374, __pyx_L6_error) if (__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L10_bool_binop_done; } __pyx_t_8 = __Pyx_HasAttr(__pyx_9genexpr46__pyx_v_o, __pyx_n_u_columns); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 5374, __pyx_L6_error) __pyx_t_5 = __pyx_t_8; __pyx_L10_bool_binop_done:; if (__pyx_t_5) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_9genexpr46__pyx_v_o))) __PYX_ERR(0, 5374, __pyx_L6_error) } } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr46__pyx_v_o); __pyx_9genexpr46__pyx_v_o = 0; goto __pyx_L13_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr46__pyx_v_o); __pyx_9genexpr46__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L13_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_2); __pyx_t_2 = 0;
5375:
+5376: is_same = set ( [ hasattr (o, '__array__')
__Pyx_TraceLine(5376,0,__PYX_ERR(0, 5376, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5376, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(5376,0,__PYX_ERR(0, 5376, __pyx_L16_error)) __pyx_t_5 = __Pyx_HasAttr(__pyx_9genexpr47__pyx_v_o, __pyx_n_u_array_2); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 5376, __pyx_L16_error) if (__pyx_t_5) { } else { __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5376, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L19_bool_binop_done; } /* … */ __Pyx_TraceLine(5376,0,__PYX_ERR(0, 5376, __pyx_L1_error)) __pyx_t_3 = PySet_New(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5376, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_is_same = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+5377: and hasattr (o, 'columns') for o in d ] )
__Pyx_TraceLine(5377,0,__PYX_ERR(0, 5377, __pyx_L16_error)) if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_3 = __pyx_v_d; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5377, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5377, __pyx_L16_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5377, __pyx_L16_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5377, __pyx_L16_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5377, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5377, __pyx_L16_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5377, __pyx_L16_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5377, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5377, __pyx_L16_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr47__pyx_v_o, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(5377,0,__PYX_ERR(0, 5377, __pyx_L16_error)) __pyx_t_5 = __Pyx_HasAttr(__pyx_9genexpr47__pyx_v_o, __pyx_n_u_columns); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 5377, __pyx_L16_error) __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5377, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = __pyx_t_9; __pyx_t_9 = 0; __pyx_L19_bool_binop_done:; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 5376, __pyx_L16_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr47__pyx_v_o); __pyx_9genexpr47__pyx_v_o = 0; goto __pyx_L22_exit_scope; __pyx_L16_error:; __Pyx_XDECREF(__pyx_9genexpr47__pyx_v_o); __pyx_9genexpr47__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L22_exit_scope:; } /* exit inner scope */
5378:
+5379: if len(is_same)!=1 or not list (is_same) [0]:
__Pyx_TraceLine(5379,0,__PYX_ERR(0, 5379, __pyx_L1_error)) __pyx_t_6 = __Pyx_PySet_GET_SIZE(__pyx_v_is_same); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5379, __pyx_L1_error) __pyx_t_8 = (__pyx_t_6 != 1); if (!__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L24_bool_binop_done; } __pyx_t_3 = PySequence_List(__pyx_v_is_same); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5379, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5379, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = (!__pyx_t_8); __pyx_t_5 = __pyx_t_10; __pyx_L24_bool_binop_done:; if (unlikely(__pyx_t_5)) { /* … */ }
+5380: types = [ type(o).__name__ for o in d ]
__Pyx_TraceLine(5380,0,__PYX_ERR(0, 5380, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5380, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_3 = __pyx_v_d; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5380, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5380, __pyx_L28_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5380, __pyx_L28_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5380, __pyx_L28_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5380, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5380, __pyx_L28_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5380, __pyx_L28_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5380, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5380, __pyx_L28_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr48__pyx_v_o, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_9genexpr48__pyx_v_o)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5380, __pyx_L28_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 5380, __pyx_L28_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr48__pyx_v_o); __pyx_9genexpr48__pyx_v_o = 0; goto __pyx_L32_exit_scope; __pyx_L28_error:; __Pyx_XDECREF(__pyx_9genexpr48__pyx_v_o); __pyx_9genexpr48__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L32_exit_scope:; } /* exit inner scope */ __pyx_v_types = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+5381: raise TypeError (
__Pyx_TraceLine(5381,0,__PYX_ERR(0, 5381, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5381, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 5381, __pyx_L1_error)
+5382: f"Expect DataFrame. Got {smart_format(types)}")
__Pyx_TraceLine(5382,0,__PYX_ERR(0, 5382, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_types}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_DataFrame_Got, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5382, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5383:
+5384: same_len = [len(o) for o in d]
__Pyx_TraceLine(5384,0,__PYX_ERR(0, 5384, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5384, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_2 = __pyx_v_d; __Pyx_INCREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5384, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5384, __pyx_L35_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5384, __pyx_L35_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5384, __pyx_L35_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5384, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5384, __pyx_L35_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5384, __pyx_L35_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5384, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5384, __pyx_L35_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr49__pyx_v_o, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_11 = PyObject_Length(__pyx_9genexpr49__pyx_v_o); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5384, __pyx_L35_error) __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5384, __pyx_L35_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 5384, __pyx_L35_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr49__pyx_v_o); __pyx_9genexpr49__pyx_v_o = 0; goto __pyx_L39_exit_scope; __pyx_L35_error:; __Pyx_XDECREF(__pyx_9genexpr49__pyx_v_o); __pyx_9genexpr49__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L39_exit_scope:; } /* exit inner scope */ __pyx_v_same_len = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
5385:
+5386: if len( set(same_len)) !=1 or not list(set(same_len))[0]:
__Pyx_TraceLine(5386,0,__PYX_ERR(0, 5386, __pyx_L1_error)) __pyx_t_3 = PySet_New(__pyx_v_same_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PySet_GET_SIZE(__pyx_t_3); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5386, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_10 = (__pyx_t_6 != 1); if (!__pyx_t_10) { } else { __pyx_t_5 = __pyx_t_10; goto __pyx_L41_bool_binop_done; } __pyx_t_3 = PySet_New(__pyx_v_same_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySequence_List(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5386, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5386, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = (!__pyx_t_10); __pyx_t_5 = __pyx_t_8; __pyx_L41_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+5387: if not coerce:
__Pyx_TraceLine(5387,0,__PYX_ERR(0, 5387, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_coerce); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5387, __pyx_L1_error) __pyx_t_8 = (!__pyx_t_5); if (unlikely(__pyx_t_8)) { /* … */ }
+5388: raise ValueError(
__Pyx_TraceLine(5388,0,__PYX_ERR(0, 5388, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5388, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 5388, __pyx_L1_error)
+5389: f"Data must be a consistent size. Got {smart_format(same_len)}"
__Pyx_TraceLine(5389,0,__PYX_ERR(0, 5389, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Data_must_be_a_consistent_size_G); __pyx_t_6 += 36; __Pyx_GIVEREF(__pyx_kp_u_Data_must_be_a_consistent_size_G); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Data_must_be_a_consistent_size_G); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_v_same_len}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_12; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_respectively_Set_coerce_True_to); __pyx_t_6 += 89; __Pyx_GIVEREF(__pyx_kp_u_respectively_Set_coerce_True_to); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_respectively_Set_coerce_True_to); __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5389, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5390: " respectively. Set ``coerce=True`` to truncate the data"
5391: " to match the shorter data length.")
5392: # get the shorthest len
+5393: min_index = min (same_len)
__Pyx_TraceLine(5393,0,__PYX_ERR(0, 5393, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_min, __pyx_v_same_len); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_min_index = __pyx_t_3; __pyx_t_3 = 0;
+5394: d = [ o.iloc [:min_index, : ] for o in d ]
__Pyx_TraceLine(5394,0,__PYX_ERR(0, 5394, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_1 = __pyx_v_d; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5394, __pyx_L46_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5394, __pyx_L46_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5394, __pyx_L46_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5394, __pyx_L46_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5394, __pyx_L46_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_7(__pyx_t_1); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5394, __pyx_L46_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_9genexpr50__pyx_v_o, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr50__pyx_v_o, __pyx_n_s_iloc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PySlice_New(Py_None, __pyx_v_min_index, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9)) __PYX_ERR(0, 5394, __pyx_L46_error); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_slice__130)) __PYX_ERR(0, 5394, __pyx_L46_error); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 5394, __pyx_L46_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr50__pyx_v_o); __pyx_9genexpr50__pyx_v_o = 0; goto __pyx_L50_exit_scope; __pyx_L46_error:; __Pyx_XDECREF(__pyx_9genexpr50__pyx_v_o); __pyx_9genexpr50__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L50_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_3); __pyx_t_3 = 0;
5395:
+5396: if on is None:
__Pyx_TraceLine(5396,0,__PYX_ERR(0, 5396, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_on == Py_None); if (__pyx_t_8) { /* … */ }
+5397: if raise_warn:
__Pyx_TraceLine(5397,0,__PYX_ERR(0, 5397, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_raise_warn); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5397, __pyx_L1_error) if (__pyx_t_8) { /* … */ }
+5398: warnings.warn("'twin_items' are missing in the data. A simple merge"
__Pyx_TraceLine(5398,0,__PYX_ERR(0, 5398, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_kp_u_twin_items_are_missing_in_the_d}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5398, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5399: " along the columns axis should be performed.")
5400:
+5401: return pd.concat ( d, axis = 1 )
__Pyx_TraceLine(5401,0,__PYX_ERR(0, 5401, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_concat); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_d)) __PYX_ERR(0, 5401, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 5401, __pyx_L1_error) __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5401, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_13; __pyx_t_13 = 0; goto __pyx_L0;
5402:
5403: # parse string
+5404: on= is_iterable(on, exclude_string= True ,
__Pyx_TraceLine(5404,0,__PYX_ERR(0, 5404, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_on); __Pyx_GIVEREF(__pyx_v_on); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_on)) __PYX_ERR(0, 5404, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 5404, __pyx_L1_error) /* … */ __Pyx_TraceLine(5404,0,__PYX_ERR(0, 5404, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_on, __pyx_t_9); __pyx_t_9 = 0;
+5405: transform =True, parse_string= parse_on
__Pyx_TraceLine(5405,0,__PYX_ERR(0, 5405, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 5404, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_parse_string, __pyx_v_parse_on) < 0) __PYX_ERR(0, 5404, __pyx_L1_error)
5406: )
5407:
+5408: feature_exist = [
__Pyx_TraceLine(5408,0,__PYX_ERR(0, 5408, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5408, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_9);
+5409: exist_features(o, on, error = 'ignore'
__Pyx_TraceLine(5409,0,__PYX_ERR(0, 5409, __pyx_L55_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_exist_features); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5409, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5409, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_INCREF(__pyx_9genexpr51__pyx_v_o); __Pyx_GIVEREF(__pyx_9genexpr51__pyx_v_o); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_9genexpr51__pyx_v_o)) __PYX_ERR(0, 5409, __pyx_L55_error); __Pyx_INCREF(__pyx_v_on); __Pyx_GIVEREF(__pyx_v_on); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_on)) __PYX_ERR(0, 5409, __pyx_L55_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5409, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_error, __pyx_n_u_ignore) < 0) __PYX_ERR(0, 5409, __pyx_L55_error) __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_13, __pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5409, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 5408, __pyx_L55_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+5410: ) for o in d ]
__Pyx_TraceLine(5410,0,__PYX_ERR(0, 5410, __pyx_L55_error)) if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_3 = __pyx_v_d; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5410, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5410, __pyx_L55_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5410, __pyx_L55_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5410, __pyx_L55_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5410, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5410, __pyx_L55_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5410, __pyx_L55_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5410, __pyx_L55_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5410, __pyx_L55_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr51__pyx_v_o, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(5410,0,__PYX_ERR(0, 5410, __pyx_L55_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr51__pyx_v_o); __pyx_9genexpr51__pyx_v_o = 0; goto __pyx_L59_exit_scope; __pyx_L55_error:; __Pyx_XDECREF(__pyx_9genexpr51__pyx_v_o); __pyx_9genexpr51__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L59_exit_scope:; } /* exit inner scope */ __pyx_v_feature_exist = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0;
5411:
+5412: if ( len( set (feature_exist) )!=1
__Pyx_TraceLine(5412,0,__PYX_ERR(0, 5412, __pyx_L1_error)) __pyx_t_9 = PySet_New(__pyx_v_feature_exist); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = __Pyx_PySet_GET_SIZE(__pyx_t_9); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5412, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_5 = (__pyx_t_6 != 1); if (!__pyx_t_5) { } else { __pyx_t_8 = __pyx_t_5; goto __pyx_L61_bool_binop_done; } /* … */ __Pyx_TraceLine(5412,0,__PYX_ERR(0, 5412, __pyx_L1_error)) if (__pyx_t_8) { /* … */ }
+5413: or not list(set(feature_exist)) [0]
__Pyx_TraceLine(5413,0,__PYX_ERR(0, 5413, __pyx_L1_error)) __pyx_t_9 = PySet_New(__pyx_v_feature_exist); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = PySequence_List(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_GetItemInt_List(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = (!__pyx_t_5); __pyx_t_8 = __pyx_t_10; __pyx_L61_bool_binop_done:;
5414: ):
+5415: if not force:
__Pyx_TraceLine(5415,0,__PYX_ERR(0, 5415, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5415, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_8); if (unlikely(__pyx_t_10)) { /* … */ }
+5416: raise ValueError(
__Pyx_TraceLine(5416,0,__PYX_ERR(0, 5416, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 5416, __pyx_L1_error)
+5417: f"Unable to fit the data. Items {smart_format(on)} are"
__Pyx_TraceLine(5417,0,__PYX_ERR(0, 5417, __pyx_L1_error)) __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Unable_to_fit_the_data_Items); __pyx_t_6 += 30; __Pyx_GIVEREF(__pyx_kp_u_Unable_to_fit_the_data_Items); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_Unable_to_fit_the_data_Items); __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_on}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_12; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_are_missing_in_the_data_columns); __pyx_t_6 += 34; __Pyx_GIVEREF(__pyx_kp_u_are_missing_in_the_data_columns); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u_are_missing_in_the_data_columns); /* … */ __Pyx_TraceLine(5417,0,__PYX_ERR(0, 5417, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_9, 5, __pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+5418: f" missing in the data columns. {smart_format(on)} must"
__Pyx_TraceLine(5418,0,__PYX_ERR(0, 5418, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_on}; __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_14, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_12; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_must_include_in_the_data_column); __pyx_t_6 += 58; __Pyx_GIVEREF(__pyx_kp_u_must_include_in_the_data_column); PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_kp_u_must_include_in_the_data_column);
5419: " include in the data columns. Please check your data.")
5420:
5421: # seek the value twin_items in the data and use if for all
+5422: dtems =[] ; repl_twd= None
__Pyx_TraceLine(5422,0,__PYX_ERR(0, 5422, __pyx_L1_error)) __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_dtems = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(Py_None); __pyx_v_repl_twd = Py_None;
+5423: for o in d:
__Pyx_TraceLine(5423,0,__PYX_ERR(0, 5423, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_9 = __pyx_v_d; __Pyx_INCREF(__pyx_t_9); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5423, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_9))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5423, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5423, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5423, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5423, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5423, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5423, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5423,0,__PYX_ERR(0, 5423, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L74_for_end; __pyx_L65_break:; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L74_for_end; __pyx_L74_for_end:;
5424: # select one valid data that contain the
5425: # twin items
+5426: try :
__Pyx_TraceLine(5426,0,__PYX_ERR(0, 5426, __pyx_L1_error)) { /*try:*/ { /* … */ } /* … */ __pyx_L68_except_error:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L1_error; __pyx_L71_try_break:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); goto __pyx_L65_break; __pyx_L67_exception_handled:; __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); }
+5427: exist_features ( o, on )
__Pyx_TraceLine(5427,0,__PYX_ERR(0, 5427, __pyx_L66_error)) __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_exist_features); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5427, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_o, __pyx_v_on}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5427, __pyx_L66_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+5428: except :
__Pyx_TraceLine(5428,0,__PYX_ERR(0, 5428, __pyx_L68_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L67_exception_handled; }
5429: pass
5430: else:
+5431: repl_twd = o [ on ]
__Pyx_TraceLine(5431,0,__PYX_ERR(0, 5431, __pyx_L68_except_error)) /*else:*/ { __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_o, __pyx_v_on); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5431, __pyx_L68_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_repl_twd, __pyx_t_3); __pyx_t_3 = 0;
+5432: break
__Pyx_TraceLine(5432,0,__PYX_ERR(0, 5432, __pyx_L68_except_error)) goto __pyx_L71_try_break; } __pyx_L66_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5433:
+5434: if repl_twd is None:
__Pyx_TraceLine(5434,0,__PYX_ERR(0, 5434, __pyx_L1_error)) __pyx_t_10 = (__pyx_v_repl_twd == Py_None); if (unlikely(__pyx_t_10)) { /* … */ }
+5435: raise ValueError("To force data that have not consistent items,"
__Pyx_TraceLine(5435,0,__PYX_ERR(0, 5435, __pyx_L1_error)) __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_To_force_data_that_have_not_cons); __pyx_t_6 += 55; __Pyx_GIVEREF(__pyx_kp_u_To_force_data_that_have_not_cons); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_kp_u_To_force_data_that_have_not_cons); /* … */ __Pyx_TraceLine(5435,0,__PYX_ERR(0, 5435, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_9, 3, __pyx_t_6, __pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 5435, __pyx_L1_error)
+5436: f" at least {smart_format(on)} items must"
__Pyx_TraceLine(5436,0,__PYX_ERR(0, 5436, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_14))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_14); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_14, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_on}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_14, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5436, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_12; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_items_must_be_included_in_one_D); __pyx_t_6 += 41; __Pyx_GIVEREF(__pyx_kp_u_items_must_be_included_in_one_D); PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_kp_u_items_must_be_included_in_one_D);
5437: " be included in one DataFrame.")
5438: # make add twin_data if
+5439: for o in d :
__Pyx_TraceLine(5439,0,__PYX_ERR(0, 5439, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_9 = __pyx_v_d; __Pyx_INCREF(__pyx_t_9); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5439, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_9))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5439, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_14); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5439, __pyx_L1_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5439, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_14); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5439, __pyx_L1_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #endif } } else { __pyx_t_14 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_14)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5439, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_14); } __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_14); __pyx_t_14 = 0; /* … */ __Pyx_TraceLine(5439,0,__PYX_ERR(0, 5439, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+5440: try : exist_features(o, on)
__Pyx_TraceLine(5440,0,__PYX_ERR(0, 5440, __pyx_L1_error)) { /*try:*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_exist_features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5440, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_o, __pyx_v_on}; __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5440, __pyx_L78_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } /* … */ __pyx_L80_except_error:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_16, __pyx_t_15); goto __pyx_L1_error; __pyx_L79_exception_handled:; __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_16, __pyx_t_15); __pyx_L85_try_end:; }
+5441: except :
__Pyx_TraceLine(5441,0,__PYX_ERR(0, 5441, __pyx_L80_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.pair_data", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 5441, __pyx_L80_except_error) __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2);
+5442: a = o.copy()
__Pyx_TraceLine(5442,0,__PYX_ERR(0, 5442, __pyx_L80_except_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5442, __pyx_L80_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_18 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_18)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL}; __pyx_t_13 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5442, __pyx_L80_except_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_13); __pyx_t_13 = 0;
+5443: a [ on ] = repl_twd
__Pyx_TraceLine(5443,0,__PYX_ERR(0, 5443, __pyx_L80_except_error)) if (unlikely((PyObject_SetItem(__pyx_v_a, __pyx_v_on, __pyx_v_repl_twd) < 0))) __PYX_ERR(0, 5443, __pyx_L80_except_error) __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L79_exception_handled; }
+5444: else : a = o.copy ()
__Pyx_TraceLine(5444,0,__PYX_ERR(0, 5444, __pyx_L80_except_error)) /*else:*/ { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5444, __pyx_L80_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5444, __pyx_L80_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_14); __pyx_t_14 = 0; } __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L85_try_end; __pyx_L78_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5445:
+5446: dtems.append(a)
__Pyx_TraceLine(5446,0,__PYX_ERR(0, 5446, __pyx_L1_error)) __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_dtems, __pyx_v_a); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 5446, __pyx_L1_error)
5447: # reinitialize d
+5448: d = dtems
__Pyx_TraceLine(5448,0,__PYX_ERR(0, 5448, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_dtems); __Pyx_DECREF_SET(__pyx_v_d, __pyx_v_dtems);
5449:
5450: # check whether values to merge are numerics
5451: # if True, use decimals to round values to consider
5452: # that identic
5453: # round value if value before performed merges
5454: # test single data with on
+5455: is_num = _is_numeric_dtype (d[0][on] )
__Pyx_TraceLine(5455,0,__PYX_ERR(0, 5455, __pyx_L1_error)) __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_d, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_v_on); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_v__is_numeric_dtype); __pyx_t_2 = __pyx_v__is_numeric_dtype; __pyx_t_14 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_t_3}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_is_num = __pyx_t_9; __pyx_t_9 = 0;
+5456: if is_num:
__Pyx_TraceLine(5456,0,__PYX_ERR(0, 5456, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_is_num); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5456, __pyx_L1_error) if (__pyx_t_10) { /* … */ }
+5457: decimals = int (_assert_all_types(
__Pyx_TraceLine(5457,0,__PYX_ERR(0, 5457, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); /* … */ __Pyx_TraceLine(5458,0,__PYX_ERR(0, 5458, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_decimals); __Pyx_GIVEREF(__pyx_v_decimals); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_decimals)) __PYX_ERR(0, 5457, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 5457, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 5457, __pyx_L1_error); /* … */ __Pyx_TraceLine(5457,0,__PYX_ERR(0, 5457, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_3)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_3))) __PYX_ERR(0, 5457, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_decimals, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
+5458: decimals, int, float, objname ='Decimals'))
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_objname, __pyx_n_u_Decimals) < 0) __PYX_ERR(0, 5458, __pyx_L1_error)
+5459: d_ = []
__Pyx_TraceLine(5459,0,__PYX_ERR(0, 5459, __pyx_L1_error)) __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_d_ = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+5460: for o in d :
__Pyx_TraceLine(5460,0,__PYX_ERR(0, 5460, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_d)) || PyTuple_CheckExact(__pyx_v_d)) { __pyx_t_3 = __pyx_v_d; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_d); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5460, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5460, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_14); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5460, __pyx_L1_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5460, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_14); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5460, __pyx_L1_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); #endif } } else { __pyx_t_14 = __pyx_t_7(__pyx_t_3); if (unlikely(!__pyx_t_14)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5460, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_14); } __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_14); __pyx_t_14 = 0; /* … */ __Pyx_TraceLine(5460,0,__PYX_ERR(0, 5460, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+5461: a = o.copy()
__Pyx_TraceLine(5461,0,__PYX_ERR(0, 5461, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_o, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL}; __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_XDECREF_SET(__pyx_v_a, __pyx_t_14); __pyx_t_14 = 0;
+5462: a[on ] = np.around (o[ on ].values, decimals )
__Pyx_TraceLine(5462,0,__PYX_ERR(0, 5462, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_around); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_o, __pyx_v_on); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_values); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_t_13, __pyx_v_decimals}; __pyx_t_14 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_a, __pyx_v_on, __pyx_t_14) < 0))) __PYX_ERR(0, 5462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+5463: d_.append (a )
__Pyx_TraceLine(5463,0,__PYX_ERR(0, 5463, __pyx_L1_error)) __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_d_, __pyx_v_a); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 5463, __pyx_L1_error)
5464: # not a numerick values so stop
+5465: d =d_
__Pyx_TraceLine(5465,0,__PYX_ERR(0, 5465, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_d_); __Pyx_DECREF_SET(__pyx_v_d, __pyx_v_d_);
5466:
5467: # select both two
+5468: data = pd.merge (* d[:2], on= on )
__Pyx_TraceLine(5468,0,__PYX_ERR(0, 5468, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_merge); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_d, 0, 2, NULL, NULL, &__pyx_slice__223, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_on, __pyx_v_on) < 0) __PYX_ERR(0, 5468, __pyx_L1_error) __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_data = __pyx_t_13; __pyx_t_13 = 0; /* … */ __pyx_slice__223 = PySlice_New(Py_None, __pyx_int_2, Py_None); if (unlikely(!__pyx_slice__223)) __PYX_ERR(0, 5468, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__223); __Pyx_GIVEREF(__pyx_slice__223);
5469:
+5470: if len(d[2:]) !=0:
__Pyx_TraceLine(5470,0,__PYX_ERR(0, 5470, __pyx_L1_error)) __pyx_t_13 = __Pyx_PyObject_GetSlice(__pyx_v_d, 2, 0, NULL, NULL, &__pyx_slice__224, 1, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_6 = PyObject_Length(__pyx_t_13); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5470, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_10 = (__pyx_t_6 != 0); if (__pyx_t_10) { /* … */ } /* … */ __pyx_slice__224 = PySlice_New(__pyx_int_2, Py_None, Py_None); if (unlikely(!__pyx_slice__224)) __PYX_ERR(0, 5470, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__224); __Pyx_GIVEREF(__pyx_slice__224);
+5471: for ii, o in enumerate ( d[2:]) :
__Pyx_TraceLine(5471,0,__PYX_ERR(0, 5471, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_13 = __pyx_int_0; __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_d, 2, 0, NULL, NULL, &__pyx_slice__224, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_9 = __pyx_t_3; __Pyx_INCREF(__pyx_t_9); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { __pyx_t_6 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5471, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_7)) { if (likely(PyList_CheckExact(__pyx_t_9))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5471, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5471, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5471, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 5471, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_7(__pyx_t_9); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5471, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_t_13); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_13); __pyx_t_3 = __Pyx_PyInt_AddObjC(__pyx_t_13, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = __pyx_t_3; __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5471,0,__PYX_ERR(0, 5471, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+5472: data = pd.merge ( *[data, o] , on = on, suffixes= (
__Pyx_TraceLine(5472,0,__PYX_ERR(0, 5472, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_merge); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_data)) __PYX_ERR(0, 5472, __pyx_L1_error); __Pyx_INCREF(__pyx_v_o); __Pyx_GIVEREF(__pyx_v_o); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_o)) __PYX_ERR(0, 5472, __pyx_L1_error); __pyx_t_2 = PySequence_Tuple(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_on, __pyx_v_on) < 0) __PYX_ERR(0, 5472, __pyx_L1_error) /* … */ __Pyx_TraceLine(5472,0,__PYX_ERR(0, 5472, __pyx_L1_error)) __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_20); __pyx_t_20 = 0;
+5473: f"_x{ii+1}", f"_y{ii+1}"))
__Pyx_TraceLine(5473,0,__PYX_ERR(0, 5473, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyInt_AddObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_n_u_x_2, __pyx_t_18); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyInt_AddObjC(__pyx_v_ii, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_20 = __Pyx_PyObject_FormatSimple(__pyx_t_18, __pyx_empty_unicode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __pyx_t_18 = __Pyx_PyUnicode_Concat(__pyx_n_u_y_5, __pyx_t_20); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_1)) __PYX_ERR(0, 5473, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_18); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_18)) __PYX_ERR(0, 5473, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_18 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_suffixes, __pyx_t_20) < 0) __PYX_ERR(0, 5472, __pyx_L1_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
5474:
+5475: return data
__Pyx_TraceLine(5475,0,__PYX_ERR(0, 5475, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
5476:
+5477: def read_worksheets(*data):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_180read_worksheets(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_179read_worksheets, " Read sheets and returns a list of DataFrames and sheet names. \n \n Parameters \n -----------\n data: list of str \n A collection of excel sheets files. Read only `.xlsx` files. Any other \n files raises an errors. \n \n Return\n ------\n data, sheet_names: Tuple of DataFrames and sheet_names \n A collection of DataFrame and sheets names. \n \n Examples \n -----------\n >>> import os \n >>> from gofast.tools.coreutils import read_worksheets \n >>> sheet_file= r'_F:\repositories\\gofast\\data\\erp\\sheets\\gbalo.xlsx'\n >>> data, snames = read_worksheets (sheet_file )\n >>> snames \n ['l11', 'l10', 'l02'] \n >>> data, snames = read_worksheets (os.path.dirname (sheet_file))\n >>> snames \n ['l11', 'l10', 'l02', 'l12', 'l13']\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_180read_worksheets = {"read_worksheets", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_180read_worksheets, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_179read_worksheets}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_180read_worksheets(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_data = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_worksheets (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_VARARGS(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "read_worksheets", 0))) return NULL; __Pyx_INCREF(__pyx_args); __pyx_v_data = __pyx_args; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_179read_worksheets(__pyx_self, __pyx_v_data); /* function exit code */ __Pyx_DECREF(__pyx_v_data); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_179read_worksheets(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets *__pyx_cur_scope; PyObject *__pyx_v_dtem = NULL; PyObject *__pyx_v_o = NULL; PyObject *__pyx_v_dlist = NULL; PyObject *__pyx_v_p = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_ex = NULL; PyObject *__pyx_v_ddict = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_sheet_names = NULL; PyObject *__pyx_9genexpr52__pyx_v_o = NULL; PyObject *__pyx_9genexpr53__pyx_v_f = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__225) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 5477, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("read_worksheets", __pyx_f[0], 5477, 0, __PYX_ERR(0, 5477, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_data); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_17); __Pyx_AddTraceback("gofast.tools.coreutils.read_worksheets", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_dtem); __Pyx_XDECREF(__pyx_v_o); __Pyx_XDECREF(__pyx_v_dlist); __Pyx_XDECREF(__pyx_v_p); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_ex); __Pyx_XDECREF(__pyx_v_ddict); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_sheet_names); __Pyx_XDECREF(__pyx_9genexpr52__pyx_v_o); __Pyx_XDECREF(__pyx_9genexpr53__pyx_v_f); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__481 = PyTuple_Pack(13, __pyx_n_s_data, __pyx_n_s_dtem, __pyx_n_s_o, __pyx_n_s_dlist, __pyx_n_s_p, __pyx_n_s__8, __pyx_n_s_ex, __pyx_n_s_ddict, __pyx_n_s_regex, __pyx_n_s_d_3, __pyx_n_s_sheet_names, __pyx_n_s_o, __pyx_n_s_f); if (unlikely(!__pyx_tuple__481)) __PYX_ERR(0, 5477, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__481); __Pyx_GIVEREF(__pyx_tuple__481); /* … */ __Pyx_TraceLine(5477,0,__PYX_ERR(0, 5477, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_180read_worksheets, 0, __pyx_n_s_read_worksheets, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__225)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_worksheets, __pyx_t_5) < 0) __PYX_ERR(0, 5477, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__225 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__481, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_read_worksheets, 5477, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__225)) __PYX_ERR(0, 5477, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets { PyObject_HEAD PyObject *__pyx_v_regex; };
5478: """ Read sheets and returns a list of DataFrames and sheet names.
5479:
5480: Parameters
5481: -----------
5482: data: list of str
5483: A collection of excel sheets files. Read only `.xlsx` files. Any other
5484: files raises an errors.
5485:
5486: Return
5487: ------
5488: data, sheet_names: Tuple of DataFrames and sheet_names
5489: A collection of DataFrame and sheets names.
5490:
5491: Examples
5492: -----------
5493: >>> import os
5494: >>> from gofast.tools.coreutils import read_worksheets
5495: >>> sheet_file= r'_F:\repositories\gofast\data\erp\sheets\gbalo.xlsx'
5496: >>> data, snames = read_worksheets (sheet_file )
5497: >>> snames
5498: ['l11', 'l10', 'l02']
5499: >>> data, snames = read_worksheets (os.path.dirname (sheet_file))
5500: >>> snames
5501: ['l11', 'l10', 'l02', 'l12', 'l13']
5502:
5503: """
+5504: dtem = []
__Pyx_TraceLine(5504,0,__PYX_ERR(0, 5504, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5504, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_dtem = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+5505: data = [o for o in data if isinstance ( o, str )]
__Pyx_TraceLine(5505,0,__PYX_ERR(0, 5505, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5505, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_2 = __pyx_v_data; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5505, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5505, __pyx_L5_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5505, __pyx_L5_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 5505, __pyx_L5_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5505, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5505, __pyx_L5_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 5505, __pyx_L5_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5505, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5505, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr52__pyx_v_o, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = PyUnicode_Check(__pyx_9genexpr52__pyx_v_o); if (__pyx_t_6) { if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_9genexpr52__pyx_v_o))) __PYX_ERR(0, 5505, __pyx_L5_error) } } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr52__pyx_v_o); __pyx_9genexpr52__pyx_v_o = 0; goto __pyx_L10_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_9genexpr52__pyx_v_o); __pyx_9genexpr52__pyx_v_o = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
5506:
+5507: for o in data:
__Pyx_TraceLine(5507,0,__PYX_ERR(0, 5507, __pyx_L1_error)) __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5507, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 5507, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_XDECREF_SET(__pyx_v_o, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(5507,0,__PYX_ERR(0, 5507, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+5508: if os.path.isdir (o):
__Pyx_TraceLine(5508,0,__PYX_ERR(0, 5508, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_path); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isdir); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_o}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5508, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5508, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ goto __pyx_L13; }
+5509: dlist = os.listdir (o)
__Pyx_TraceLine(5509,0,__PYX_ERR(0, 5509, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_listdir); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_o}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5509, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_dlist, __pyx_t_2); __pyx_t_2 = 0;
5510: # collect only the excell sheets
+5511: p = [ os.path.join(o, f) for f in dlist if f.endswith ('.xlsx') ]
__Pyx_TraceLine(5511,0,__PYX_ERR(0, 5511, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_v_dlist)) || PyTuple_CheckExact(__pyx_v_dlist)) { __pyx_t_7 = __pyx_v_dlist; __Pyx_INCREF(__pyx_t_7); __pyx_t_9 = 0; __pyx_t_4 = NULL; } else { __pyx_t_9 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_dlist); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5511, __pyx_L16_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5511, __pyx_L16_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 5511, __pyx_L16_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5511, __pyx_L16_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_5); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 5511, __pyx_L16_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_4(__pyx_t_7); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5511, __pyx_L16_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr53__pyx_v_f, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr53__pyx_v_f, __pyx_n_s_endswith); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_kp_u_xlsx}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_6) { __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_os); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_join); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_v_o, __pyx_9genexpr53__pyx_v_f}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_8, 2+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 5511, __pyx_L16_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_9genexpr53__pyx_v_f); __pyx_9genexpr53__pyx_v_f = 0; goto __pyx_L21_exit_scope; __pyx_L16_error:; __Pyx_XDECREF(__pyx_9genexpr53__pyx_v_f); __pyx_9genexpr53__pyx_v_f = 0; goto __pyx_L1_error; __pyx_L21_exit_scope:; } /* exit inner scope */ __Pyx_XDECREF_SET(__pyx_v_p, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
+5512: dtem .extend(p)
__Pyx_TraceLine(5512,0,__PYX_ERR(0, 5512, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyList_Extend(__pyx_v_dtem, __pyx_v_p); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 5512, __pyx_L1_error)
+5513: elif os.path.isfile (o):
__Pyx_TraceLine(5513,0,__PYX_ERR(0, 5513, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_isfile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_o}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5513, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5513, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ } __pyx_L13:;
+5514: _, ex = os.path.splitext( o)
__Pyx_TraceLine(5514,0,__PYX_ERR(0, 5514, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_splitext); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_o}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5514, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5514, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); index = 0; __pyx_t_7 = __pyx_t_13(__pyx_t_10); if (unlikely(!__pyx_t_7)) goto __pyx_L22_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); index = 1; __pyx_t_5 = __pyx_t_13(__pyx_t_10); if (unlikely(!__pyx_t_5)) goto __pyx_L22_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_10), 2) < 0) __PYX_ERR(0, 5514, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L23_unpacking_done; __pyx_L22_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 5514, __pyx_L1_error) __pyx_L23_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_v__, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_ex, __pyx_t_5); __pyx_t_5 = 0;
+5515: if ex == '.xlsx':
__Pyx_TraceLine(5515,0,__PYX_ERR(0, 5515, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_ex, __pyx_kp_u_xlsx, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5515, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+5516: dtem.append(o)
__Pyx_TraceLine(5516,0,__PYX_ERR(0, 5516, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_dtem, __pyx_v_o); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 5516, __pyx_L1_error)
5517:
+5518: data = copy.deepcopy(dtem)
__Pyx_TraceLine(5518,0,__PYX_ERR(0, 5518, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_dtem}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5518, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
5519: # if no excel sheets is found return None
+5520: if len(data) ==0:
__Pyx_TraceLine(5520,0,__PYX_ERR(0, 5520, __pyx_L1_error)) __pyx_t_3 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5520, __pyx_L1_error) __pyx_t_6 = (__pyx_t_3 == 0); if (__pyx_t_6) { /* … */ }
+5521: return None, None
__Pyx_TraceLine(5521,0,__PYX_ERR(0, 5521, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_tuple__226); __pyx_r = __pyx_tuple__226; goto __pyx_L0; /* … */ __pyx_tuple__226 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__226)) __PYX_ERR(0, 5521, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__226); __Pyx_GIVEREF(__pyx_tuple__226);
5522:
5523: # make d dict to collect data
+5524: ddict = dict()
__Pyx_TraceLine(5524,0,__PYX_ERR(0, 5524, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5524, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_ddict = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+5525: regex = re.compile (r'[$& #@%^!]', flags=re.IGNORECASE)
__Pyx_TraceLine(5525,0,__PYX_ERR(0, 5525, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_flags, __pyx_t_7) < 0) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_tuple__228, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_7); __pyx_cur_scope->__pyx_v_regex = __pyx_t_7; __pyx_t_7 = 0; /* … */ __pyx_tuple__228 = PyTuple_Pack(1, __pyx_kp_u__227); if (unlikely(!__pyx_tuple__228)) __PYX_ERR(0, 5525, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__228); __Pyx_GIVEREF(__pyx_tuple__228);
5526:
+5527: for d in data :
__Pyx_TraceLine(5527,0,__PYX_ERR(0, 5527, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_data)) || PyTuple_CheckExact(__pyx_v_data)) { __pyx_t_7 = __pyx_v_data; __Pyx_INCREF(__pyx_t_7); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { __pyx_t_3 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_data); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5527, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_4)) { if (likely(PyList_CheckExact(__pyx_t_7))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5527, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 5527, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5527, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 5527, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5527, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_4(__pyx_t_7); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5527, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(5527,0,__PYX_ERR(0, 5527, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+5528: try:
__Pyx_TraceLine(5528,0,__PYX_ERR(0, 5528, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; goto __pyx_L36_try_end; __pyx_L29_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L31_except_error:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); goto __pyx_L1_error; __pyx_L30_exception_handled:; __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16); __pyx_L36_try_end:; }
+5529: ddict.update ( **pd.read_excel (d , sheet_name =None))
__Pyx_TraceLine(5529,0,__PYX_ERR(0, 5529, __pyx_L29_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_ddict, __pyx_n_s_update); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_read_excel); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_d)) __PYX_ERR(0, 5529, __pyx_L29_error); __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_11); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_sheet_name, Py_None) < 0) __PYX_ERR(0, 5529, __pyx_L29_error) __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_2, __pyx_t_11); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(__pyx_t_17 == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 5529, __pyx_L29_error) } if (likely(PyDict_CheckExact(__pyx_t_17))) { __pyx_t_5 = PyDict_Copy(__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } else { __pyx_t_5 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; } __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5529, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+5530: except : pass
__Pyx_TraceLine(5530,0,__PYX_ERR(0, 5530, __pyx_L31_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L30_exception_handled; }
5531:
5532: #collect stations names
+5533: if len(ddict)==0 :
__Pyx_TraceLine(5533,0,__PYX_ERR(0, 5533, __pyx_L1_error)) __pyx_t_3 = PyDict_Size(__pyx_v_ddict); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5533, __pyx_L1_error) __pyx_t_6 = (__pyx_t_3 == 0); if (unlikely(__pyx_t_6)) { /* … */ }
+5534: raise TypeError("Can'find the data to read.")
__Pyx_TraceLine(5534,0,__PYX_ERR(0, 5534, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__229, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5534, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 5534, __pyx_L1_error) /* … */ __pyx_tuple__229 = PyTuple_Pack(1, __pyx_kp_u_Can_find_the_data_to_read); if (unlikely(!__pyx_tuple__229)) __PYX_ERR(0, 5534, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__229); __Pyx_GIVEREF(__pyx_tuple__229);
5535:
+5536: sheet_names = list(map(
__Pyx_TraceLine(5536,0,__PYX_ERR(0, 5536, __pyx_L1_error)) __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7)) __PYX_ERR(0, 5536, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_17); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_17)) __PYX_ERR(0, 5536, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_17 = 0; __pyx_t_17 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_5, NULL); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PySequence_ListKeepNew(__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5536, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __pyx_v_sheet_names = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+5537: lambda o: regex.sub('_', o).lower(), ddict.keys()))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_15read_worksheets_lambda18(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_15read_worksheets_lambda18 = {"lambda18", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_15read_worksheets_lambda18, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_15read_worksheets_lambda18(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_o = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda18 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_o,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_o)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5537, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda18") < 0)) __PYX_ERR(0, 5537, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_o = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda18", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5537, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.read_worksheets.lambda18", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda18(__pyx_self, __pyx_v_o);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda18(PyObject *__pyx_self, PyObject *__pyx_v_o) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_18_read_worksheets *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda18", __pyx_f[0], 5537, 0, __PYX_ERR(0, 5537, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_regex)) { __Pyx_RaiseClosureNameError("regex"); __PYX_ERR(0, 5537, __pyx_L1_error) }
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_regex, __pyx_n_s_sub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5537, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_n_u__8, __pyx_v_o};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5537, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5537, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_2)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_2);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5537, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.read_worksheets.lambda18", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(5537,0,__PYX_ERR(0, 5537, __pyx_L1_error))
__pyx_t_7 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_15read_worksheets_lambda18, 0, __pyx_n_s_read_worksheets_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5537, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_17 = __Pyx_PyDict_Keys(__pyx_v_ddict); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5537, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_17);
5538:
+5539: data = list(ddict.values ())
__Pyx_TraceLine(5539,0,__PYX_ERR(0, 5539, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_Values(__pyx_v_ddict); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5539, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_17 = __Pyx_PySequence_ListKeepNew(__pyx_t_5); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5539, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_17); __pyx_t_17 = 0;
5540:
+5541: return data, sheet_names
__Pyx_TraceLine(5541,0,__PYX_ERR(0, 5541, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_17 = PyTuple_New(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_v_data)) __PYX_ERR(0, 5541, __pyx_L1_error); __Pyx_INCREF(__pyx_v_sheet_names); __Pyx_GIVEREF(__pyx_v_sheet_names); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_v_sheet_names)) __PYX_ERR(0, 5541, __pyx_L1_error); __pyx_r = __pyx_t_17; __pyx_t_17 = 0; goto __pyx_L0;
5542:
+5543: def key_checker (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_182key_checker(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_181key_checker, "check whether a give key exists in valid_keys and return a list if \n many keys are found.\n \n Parameters \n -----------\n keys: str, list of str \n Key value to find in the valid_keys \n \n valid_keys: list \n List of valid keys by default. \n \n regex: `re` object, \n Regular expresion object. the default is:: \n \n >>> import re \n >>> re.compile (r'[_#&*@!_,;\\s-]\\s*', flags=re.IGNORECASE)\n \n pattern: str, default = '[_#&*@!_,;\\s-]\\s*'\n The base pattern to split the text into a columns\n \n deep_search: bool, default=False \n If deep-search, the key finder is no sensistive to lower/upper case \n or whether a numeric data is included. \n \n \n Returns \n --------\n keys: str, list , \n List of keys that exists in the `valid_keys`. \n \n Examples\n --------\n \n >>> from gofast.tools.coreutils import key_checker\n >>> key_checker('h502', valid_keys= ['h502', 'h253','h2601']) \n Out[68]: 'h502'\n >>> key_checker('h502+h2601', valid_keys= ['h502', 'h253','h2601'])\n Out[69]: ['h502', 'h2601']\n >>> key_checker('h502 h2601', valid_keys= ['h502', 'h253','h2601'])\n Out[70]: ['h502', 'h2601']\n >>> key_checker(['h502', 'h2601'], valid_keys= ['h502', 'h253','h2601'])\n Out[73]: ['h502', 'h2601']\n >>> key_checker(['h502', 'h2602'], valid_keys= ['h502', 'h253','h2601'])\n UserWarning: key 'h2602' is missing in ['h502', 'h2602']\n Out[82]: 'h502'\n >>> key_checker(['502', 'H2601'], valid_keys= ['h502', 'h253','h2601'], \n deep_search=True )\n Out[57]: ['h502', 'h2601']\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_182key_checker = {"key_checker", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_182key_checker, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_181key_checker}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_182key_checker(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_keys = 0; PyObject *__pyx_v_valid_keys = 0; PyObject *__pyx_v_regex = 0; PyObject *__pyx_v_pattern = 0; PyObject *__pyx_v_deep_search = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("key_checker (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_keys,&__pyx_n_s_valid_keys,&__pyx_n_s_regex,&__pyx_n_s_pattern,&__pyx_n_s_deep_search,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_181key_checker(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_keys, PyObject *__pyx_v_valid_keys, PyObject *__pyx_v_regex, PyObject *__pyx_v_pattern, PyObject *__pyx_v_deep_search) { PyObject *__pyx_v__keys = NULL; PyObject *__pyx_v_kkeys = NULL; PyObject *__pyx_v_verb1 = NULL; PyObject *__pyx_v_verb2 = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_v_miss_keys = NULL; PyObject *__pyx_v_verb = NULL; Py_UCS4 __pyx_9genexpr54__pyx_v_k; PyObject *__pyx_9genexpr55__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__230) __Pyx_TraceCall("key_checker", __pyx_f[0], 5543, 0, __PYX_ERR(0, 5543, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_keys); __Pyx_INCREF(__pyx_v_valid_keys); __Pyx_INCREF(__pyx_v_pattern); __Pyx_INCREF(__pyx_v_deep_search); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_17); __Pyx_AddTraceback("gofast.tools.coreutils.key_checker", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__keys); __Pyx_XDECREF(__pyx_v_kkeys); __Pyx_XDECREF(__pyx_v_verb1); __Pyx_XDECREF(__pyx_v_verb2); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XDECREF(__pyx_v_miss_keys); __Pyx_XDECREF(__pyx_v_verb); __Pyx_XDECREF(__pyx_9genexpr55__pyx_v_i); __Pyx_XDECREF(__pyx_v_keys); __Pyx_XDECREF(__pyx_v_valid_keys); __Pyx_XDECREF(__pyx_v_pattern); __Pyx_XDECREF(__pyx_v_deep_search); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__482 = PyTuple_Pack(14, __pyx_n_s_keys, __pyx_n_s_valid_keys, __pyx_n_s_regex, __pyx_n_s_pattern, __pyx_n_s_deep_search, __pyx_n_s_keys_2, __pyx_n_s_kkeys, __pyx_n_s_verb1, __pyx_n_s_verb2, __pyx_n_s_msg, __pyx_n_s_miss_keys, __pyx_n_s_verb, __pyx_n_s_k, __pyx_n_s_i); if (unlikely(!__pyx_tuple__482)) __PYX_ERR(0, 5543, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__482); __Pyx_GIVEREF(__pyx_tuple__482); __pyx_codeobj__230 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__482, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_key_checker, 5543, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__230)) __PYX_ERR(0, 5543, __pyx_L1_error) /* … */ __Pyx_TraceLine(5543,0,__PYX_ERR(0, 5543, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_keys, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 5543, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_valid_keys, __pyx_kp_s_List_str) < 0) __PYX_ERR(0, 5543, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_regex, __pyx_n_s_re) < 0) __PYX_ERR(0, 5543, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 5543, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_deep_search, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5543, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_182key_checker, 0, __pyx_n_s_key_checker, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__230)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5543, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__483); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_key_checker, __pyx_t_2) < 0) __PYX_ERR(0, 5543, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__483 = PyTuple_Pack(3, Py_None, Py_None, ((PyObject *)Py_Ellipsis)); if (unlikely(!__pyx_tuple__483)) __PYX_ERR(0, 5543, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__483); __Pyx_GIVEREF(__pyx_tuple__483);
5544: keys: str ,
5545: valid_keys:List[str],
+5546: regex:re = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+5547: pattern:str = None ,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+5548: deep_search:bool =...
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_keys)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5543, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_valid_keys)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5543, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("key_checker", 0, 2, 5, 1); __PYX_ERR(0, 5543, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5543, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5543, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep_search); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5543, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "key_checker") < 0)) __PYX_ERR(0, 5543, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_keys = ((PyObject*)values[0]); __pyx_v_valid_keys = values[1]; __pyx_v_regex = values[2]; __pyx_v_pattern = ((PyObject*)values[3]); __pyx_v_deep_search = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("key_checker", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 5543, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.key_checker", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_keys), (&PyUnicode_Type), 0, "keys", 1))) __PYX_ERR(0, 5544, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern), (&PyUnicode_Type), 1, "pattern", 1))) __PYX_ERR(0, 5547, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_181key_checker(__pyx_self, __pyx_v_keys, __pyx_v_valid_keys, __pyx_v_regex, __pyx_v_pattern, __pyx_v_deep_search);
5549: ):
5550: """check whether a give key exists in valid_keys and return a list if
5551: many keys are found.
5552:
5553: Parameters
5554: -----------
5555: keys: str, list of str
5556: Key value to find in the valid_keys
5557:
5558: valid_keys: list
5559: List of valid keys by default.
5560:
5561: regex: `re` object,
5562: Regular expresion object. the default is::
5563:
5564: >>> import re
5565: >>> re.compile (r'[_#&*@!_,;\s-]\s*', flags=re.IGNORECASE)
5566:
5567: pattern: str, default = '[_#&*@!_,;\s-]\s*'
5568: The base pattern to split the text into a columns
5569:
5570: deep_search: bool, default=False
5571: If deep-search, the key finder is no sensistive to lower/upper case
5572: or whether a numeric data is included.
5573:
5574:
5575: Returns
5576: --------
5577: keys: str, list ,
5578: List of keys that exists in the `valid_keys`.
5579:
5580: Examples
5581: --------
5582:
5583: >>> from gofast.tools.coreutils import key_checker
5584: >>> key_checker('h502', valid_keys= ['h502', 'h253','h2601'])
5585: Out[68]: 'h502'
5586: >>> key_checker('h502+h2601', valid_keys= ['h502', 'h253','h2601'])
5587: Out[69]: ['h502', 'h2601']
5588: >>> key_checker('h502 h2601', valid_keys= ['h502', 'h253','h2601'])
5589: Out[70]: ['h502', 'h2601']
5590: >>> key_checker(['h502', 'h2601'], valid_keys= ['h502', 'h253','h2601'])
5591: Out[73]: ['h502', 'h2601']
5592: >>> key_checker(['h502', 'h2602'], valid_keys= ['h502', 'h253','h2601'])
5593: UserWarning: key 'h2602' is missing in ['h502', 'h2602']
5594: Out[82]: 'h502'
5595: >>> key_checker(['502', 'H2601'], valid_keys= ['h502', 'h253','h2601'],
5596: deep_search=True )
5597: Out[57]: ['h502', 'h2601']
5598:
5599: """
+5600: deep_search, =ellipsis2false(deep_search)
__Pyx_TraceLine(5600,0,__PYX_ERR(0, 5600, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ellipsis2false); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_deep_search}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 1)) { if (size > 1) __Pyx_RaiseTooManyValuesError(1); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5600, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); } __Pyx_INCREF(__pyx_t_2); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); index = 0; __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_3), 1) < 0) __PYX_ERR(0, 5600, __pyx_L1_error) __pyx_t_5 = NULL; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 5600, __pyx_L1_error) __pyx_L4_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_deep_search, __pyx_t_2); __pyx_t_2 = 0;
5601:
+5602: _keys = copy.deepcopy(keys)
__Pyx_TraceLine(5602,0,__PYX_ERR(0, 5602, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_keys}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v__keys = __pyx_t_1; __pyx_t_1 = 0;
+5603: valid_keys = is_iterable(valid_keys , exclude_string =True, transform =True )
__Pyx_TraceLine(5603,0,__PYX_ERR(0, 5603, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_valid_keys); __Pyx_GIVEREF(__pyx_v_valid_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_valid_keys)) __PYX_ERR(0, 5603, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 5603, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 5603, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5603, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_valid_keys, __pyx_t_6); __pyx_t_6 = 0;
+5604: if isinstance ( keys, str):
__Pyx_TraceLine(5604,0,__PYX_ERR(0, 5604, __pyx_L1_error)) __pyx_t_7 = PyUnicode_Check(__pyx_v_keys); if (__pyx_t_7) { /* … */ }
+5605: pattern = pattern or '[_#&@!_+,;\s-]\s*'
__Pyx_TraceLine(5605,0,__PYX_ERR(0, 5605, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_pattern); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 5605, __pyx_L1_error) if (!__pyx_t_7) { } else { __Pyx_INCREF(__pyx_v_pattern); __pyx_t_6 = __pyx_v_pattern; goto __pyx_L6_bool_binop_done; } __Pyx_INCREF(__pyx_kp_u_s_s_4); __pyx_t_6 = __pyx_kp_u_s_s_4; __pyx_L6_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_pattern, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
+5606: keys = str2columns (keys, regex = regex , pattern=pattern )
__Pyx_TraceLine(5606,0,__PYX_ERR(0, 5606, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_keys); __Pyx_GIVEREF(__pyx_v_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_keys)) __PYX_ERR(0, 5606, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_regex, __pyx_v_regex) < 0) __PYX_ERR(0, 5606, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 5606, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 5606, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
5607: # If iterbale object , save obj
5608: # to improve error
+5609: kkeys = copy.deepcopy(keys)
__Pyx_TraceLine(5609,0,__PYX_ERR(0, 5609, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5609, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5609, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_keys}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5609, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_kkeys = __pyx_t_1; __pyx_t_1 = 0;
+5610: if deep_search:
__Pyx_TraceLine(5610,0,__PYX_ERR(0, 5610, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_deep_search); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 5610, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+5611: keys = key_search(
__Pyx_TraceLine(5611,0,__PYX_ERR(0, 5611, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_key_search); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(5612,0,__PYX_ERR(0, 5612, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_keys); __Pyx_GIVEREF(__pyx_v_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_keys)) __PYX_ERR(0, 5611, __pyx_L1_error); /* … */ __Pyx_TraceLine(5611,0,__PYX_ERR(0, 5611, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_6))) __PYX_ERR(0, 5611, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
5612: keys,
+5613: default_keys= valid_keys,
__Pyx_TraceLine(5613,0,__PYX_ERR(0, 5613, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5613, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_default_keys, __pyx_v_valid_keys) < 0) __PYX_ERR(0, 5613, __pyx_L1_error)
+5614: deep=True,
__Pyx_TraceLine(5614,0,__PYX_ERR(0, 5614, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_deep, Py_True) < 0) __PYX_ERR(0, 5613, __pyx_L1_error)
+5615: raise_exception= True,
__Pyx_TraceLine(5615,0,__PYX_ERR(0, 5615, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_raise_exception, Py_True) < 0) __PYX_ERR(0, 5613, __pyx_L1_error)
+5616: regex =regex,
__Pyx_TraceLine(5616,0,__PYX_ERR(0, 5616, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_regex, __pyx_v_regex) < 0) __PYX_ERR(0, 5613, __pyx_L1_error)
+5617: pattern=pattern
__Pyx_TraceLine(5617,0,__PYX_ERR(0, 5617, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 5613, __pyx_L1_error)
5618: )
+5619: return keys[0] if len(keys)==1 else keys
__Pyx_TraceLine(5619,0,__PYX_ERR(0, 5619, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_keys == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 5619, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_keys); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5619, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 == 1); if (__pyx_t_7) { __pyx_t_9 = __Pyx_GetItemInt_Unicode(__pyx_v_keys, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_9 == (Py_UCS4)-1)) __PYX_ERR(0, 5619, __pyx_L1_error) __pyx_t_3 = __Pyx_PyUnicode_FromOrdinal(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_keys); __pyx_t_6 = __pyx_v_keys; } __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
5620: # for consistency
+5621: keys = [ k for k in keys if ''.join(
__Pyx_TraceLine(5621,0,__PYX_ERR(0, 5621, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(__pyx_v_keys == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); __PYX_ERR(0, 5621, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_keys); __pyx_t_10 = __pyx_v_keys; __pyx_t_13 = __Pyx_init_unicode_iteration(__pyx_t_10, (&__pyx_t_11), (&__pyx_t_12), (&__pyx_t_4)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 5621, __pyx_L1_error) for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_11; __pyx_t_14++) { __pyx_t_8 = __pyx_t_14; __pyx_9genexpr54__pyx_v_k = __Pyx_PyUnicode_READ(__pyx_t_4, __pyx_t_12, __pyx_t_8); /* … */ __Pyx_TraceLine(5622,0,__PYX_ERR(0, 5622, __pyx_L1_error)) { /* enter inner scope */ /* … */ __Pyx_TraceLine(5621,0,__PYX_ERR(0, 5621, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__22, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5621,0,__PYX_ERR(0, 5621, __pyx_L1_error)) if (__pyx_t_7) { __pyx_t_2 = __Pyx_PyUnicode_FromOrdinal(__pyx_9genexpr54__pyx_v_k); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 5621, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } /* exit inner scope */ if (!(likely(PyUnicode_CheckExact(__pyx_t_6)) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_6))) __PYX_ERR(0, 5621, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
+5622: [ str(i) for i in valid_keys] ).find(k)>=0 ]
__pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5622, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_v_valid_keys)) || PyTuple_CheckExact(__pyx_v_valid_keys)) { __pyx_t_2 = __pyx_v_valid_keys; __Pyx_INCREF(__pyx_t_2); __pyx_t_15 = 0; __pyx_t_16 = NULL; } else { __pyx_t_15 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_valid_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5622, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_16 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5622, __pyx_L14_error) } for (;;) { if (likely(!__pyx_t_16)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5622, __pyx_L14_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_15); __Pyx_INCREF(__pyx_t_1); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 5622, __pyx_L14_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5622, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5622, __pyx_L14_error) #endif if (__pyx_t_15 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_15); __Pyx_INCREF(__pyx_t_1); __pyx_t_15++; if (unlikely((0 < 0))) __PYX_ERR(0, 5622, __pyx_L14_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5622, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_16(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5622, __pyx_L14_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr55__pyx_v_i, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Str(__pyx_9genexpr55__pyx_v_i); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5622, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 5622, __pyx_L14_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr55__pyx_v_i); __pyx_9genexpr55__pyx_v_i = 0; goto __pyx_L18_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_9genexpr55__pyx_v_i); __pyx_9genexpr55__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L18_exit_scope:; } /* exit inner scope */ /* … */ __Pyx_TraceLine(5622,0,__PYX_ERR(0, 5622, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_FromOrdinal(__pyx_9genexpr54__pyx_v_k); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = PyUnicode_Find(((PyObject*)__pyx_t_2), __pyx_t_3, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-2))) __PYX_ERR(0, 5622, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5622, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 5622, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5623: # assertion error if key does not exist.
+5624: if len(keys)==0:
__Pyx_TraceLine(5624,0,__PYX_ERR(0, 5624, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_keys); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5624, __pyx_L1_error) __pyx_t_7 = (__pyx_t_11 == 0); if (unlikely(__pyx_t_7)) { /* … */ }
+5625: verb1, verb2 = ('', 'es') if len(kkeys)==1 else ('s', '')
__Pyx_TraceLine(5625,0,__PYX_ERR(0, 5625, __pyx_L1_error)) __pyx_t_11 = PyObject_Length(__pyx_v_kkeys); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5625, __pyx_L1_error) __pyx_t_7 = (__pyx_t_11 == 1); if (__pyx_t_7) { __Pyx_INCREF(__pyx_tuple__231); __pyx_t_6 = __pyx_tuple__231; } else { /* … */ __pyx_tuple__231 = PyTuple_Pack(2, __pyx_kp_u__22, __pyx_n_u_es); if (unlikely(!__pyx_tuple__231)) __PYX_ERR(0, 5625, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__231); __Pyx_GIVEREF(__pyx_tuple__231); __Pyx_INCREF(__pyx_tuple__232); __pyx_t_6 = __pyx_tuple__232; } if (likely(__pyx_t_6 != Py_None)) { PyObject* sequence = __pyx_t_6; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5625, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 5625, __pyx_L1_error) } __pyx_v_verb1 = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_verb2 = __pyx_t_3; __pyx_t_3 = 0; __pyx_tuple__232 = PyTuple_Pack(2, __pyx_n_u_s_2, __pyx_kp_u__22); if (unlikely(!__pyx_tuple__232)) __PYX_ERR(0, 5625, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__232); __Pyx_GIVEREF(__pyx_tuple__232);
+5626: msg = (f"key{verb1} {_keys!r} do{verb2} not exist."
__Pyx_TraceLine(5626,0,__PYX_ERR(0, 5626, __pyx_L1_error)) __pyx_t_6 = PyTuple_New(8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = 0; __pyx_t_9 = 127; __Pyx_INCREF(__pyx_n_u_key); __pyx_t_11 += 3; __Pyx_GIVEREF(__pyx_n_u_key); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_n_u_key); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_verb1, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_9; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_11 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u__14); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v__keys), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_9; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_do); __pyx_t_11 += 3; __Pyx_GIVEREF(__pyx_kp_u_do); PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_kp_u_do); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_verb2, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_9; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_not_exist_Expect); __pyx_t_11 += 19; __Pyx_GIVEREF(__pyx_kp_u_not_exist_Expect); PyTuple_SET_ITEM(__pyx_t_6, 6, __pyx_kp_u_not_exist_Expect); /* … */ __Pyx_TraceLine(5626,0,__PYX_ERR(0, 5626, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_6, 8, __pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5626, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_msg = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+5627: f" Expect {smart_format(valid_keys, 'or')}")
__Pyx_TraceLine(5627,0,__PYX_ERR(0, 5627, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_v_valid_keys, __pyx_n_u_or}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_9; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 7, __pyx_t_2); __pyx_t_2 = 0;
+5628: raise KeyError ( msg )
__Pyx_TraceLine(5628,0,__PYX_ERR(0, 5628, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_v_msg); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 5628, __pyx_L1_error)
5629:
+5630: if len(keys) != len(kkeys):
__Pyx_TraceLine(5630,0,__PYX_ERR(0, 5630, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_keys); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5630, __pyx_L1_error) __pyx_t_8 = PyObject_Length(__pyx_v_kkeys); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5630, __pyx_L1_error) __pyx_t_7 = (__pyx_t_11 != __pyx_t_8); if (__pyx_t_7) { /* … */ }
+5631: miss_keys = is_in_if ( kkeys, keys , return_diff= True , error ='ignore')
__Pyx_TraceLine(5631,0,__PYX_ERR(0, 5631, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_in_if); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_kkeys); __Pyx_GIVEREF(__pyx_v_kkeys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_kkeys)) __PYX_ERR(0, 5631, __pyx_L1_error); __Pyx_INCREF(__pyx_v_keys); __Pyx_GIVEREF(__pyx_v_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_keys)) __PYX_ERR(0, 5631, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_return_diff, Py_True) < 0) __PYX_ERR(0, 5631, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_error, __pyx_n_u_ignore) < 0) __PYX_ERR(0, 5631, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_miss_keys = __pyx_t_1; __pyx_t_1 = 0;
+5632: miss_keys, verb = (miss_keys[0], 'is') if len( miss_keys) ==1 else (
__Pyx_TraceLine(5632,0,__PYX_ERR(0, 5632, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_miss_keys); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5632, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 == 1); if (__pyx_t_7) { __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_miss_keys, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3)) __PYX_ERR(0, 5632, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_is_2); __Pyx_GIVEREF(__pyx_n_u_is_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_is_2)) __PYX_ERR(0, 5632, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; } else { /* … */ __Pyx_TraceLine(5632,0,__PYX_ERR(0, 5632, __pyx_L1_error)) __Pyx_DECREF_SET(__pyx_v_miss_keys, __pyx_t_6); __pyx_t_6 = 0; __pyx_v_verb = __pyx_t_3; __pyx_t_3 = 0;
+5633: miss_keys, 'are')
__Pyx_TraceLine(5633,0,__PYX_ERR(0, 5633, __pyx_L1_error)) __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5633, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_miss_keys); __Pyx_GIVEREF(__pyx_v_miss_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_miss_keys)) __PYX_ERR(0, 5633, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_are); __Pyx_GIVEREF(__pyx_n_u_are); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_n_u_are)) __PYX_ERR(0, 5633, __pyx_L1_error); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; } if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 5632, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5632, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 5632, __pyx_L1_error) }
+5634: warnings.warn(f"key{'' if verb=='is' else 's'} {miss_keys!r} {verb}"
__Pyx_TraceLine(5634,0,__PYX_ERR(0, 5634, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_warnings); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_warn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyTuple_New(8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_9 = 127; __Pyx_INCREF(__pyx_n_u_key); __pyx_t_8 += 3; __Pyx_GIVEREF(__pyx_n_u_key); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_n_u_key); __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_verb, __pyx_n_u_is_2, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 5634, __pyx_L1_error) if (__pyx_t_7) { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_2 = __pyx_kp_u__22; } else { __Pyx_INCREF(__pyx_n_u_s_2); __pyx_t_2 = __pyx_n_u_s_2; } __pyx_t_17 = __Pyx_PyUnicode_Unicode(__pyx_t_2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) : __pyx_t_9; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_17); __pyx_t_17 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__14); __pyx_t_17 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_miss_keys), __pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) : __pyx_t_9; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_17); __pyx_t_17 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u__14); __pyx_t_17 = __Pyx_PyObject_FormatSimple(__pyx_v_verb, __pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) : __pyx_t_9; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_t_17); __pyx_t_17 = 0; __Pyx_INCREF(__pyx_kp_u_missing_in); __pyx_t_8 += 12; __Pyx_GIVEREF(__pyx_kp_u_missing_in); PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_kp_u_missing_in); /* … */ __Pyx_TraceLine(5634,0,__PYX_ERR(0, 5634, __pyx_L1_error)) __pyx_t_17 = __Pyx_PyUnicode_Join(__pyx_t_3, 8, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_17}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+5635: f" missing in {_keys}")
__Pyx_TraceLine(5635,0,__PYX_ERR(0, 5635, __pyx_L1_error)) __pyx_t_17 = __Pyx_PyObject_FormatSimple(__pyx_v__keys, __pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5635, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_17) : __pyx_t_9; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_17); __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_3, 7, __pyx_t_17); __pyx_t_17 = 0;
+5636: keys = keys[0] if len(keys)==1 else keys
__Pyx_TraceLine(5636,0,__PYX_ERR(0, 5636, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_keys); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5636, __pyx_L1_error) __pyx_t_7 = (__pyx_t_8 == 1); if (__pyx_t_7) { __pyx_t_9 = __Pyx_GetItemInt_Unicode(__pyx_v_keys, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_9 == (Py_UCS4)-1)) __PYX_ERR(0, 5636, __pyx_L1_error) __pyx_t_6 = __Pyx_PyUnicode_FromOrdinal(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5636, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; } else { __Pyx_INCREF(__pyx_v_keys); __pyx_t_1 = __pyx_v_keys; } __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
5637:
+5638: return keys
__Pyx_TraceLine(5638,0,__PYX_ERR(0, 5638, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_keys); __pyx_r = __pyx_v_keys; goto __pyx_L0;
5639:
+5640: def random_sampling (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_184random_sampling(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_183random_sampling, " Sampling data. \n \n Parameters \n ----------\n d: {array-like, sparse matrix} of shape (n_samples, n_features)\n Data for sampling, where `n_samples` is the number of samples and\n `n_features` is the number of features.\n samples: int,optional \n Ratio or number of items from axis to return. \n Default = 1 if `samples` is ``None``.\n \n replace: bool, default=False\n Allow or disallow sampling of the same row more than once. \n \n random_state: int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional\n If int, array-like, or BitGenerator, seed for random number generator. \n If np.random.RandomState or np.random.Generator, use as given.\n \n shuffle:bool, default=True \n Shuffle the data before sampling \n \n Returns \n ----------\n d: {array-like, sparse matrix} of shape (n_samples, n_features)\n samples data based on the given samples. \n \n Examples\n ---------\n >>> from gofast.tools.coreutils import random_sampling \n >>> from gofast.datasets import load_hlogs \n >>> data= load_hlogs().frame\n >>> random_sampling( data, samples = 7 ).shape \n (7, 27)\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_184random_sampling = {"random_sampling", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_184random_sampling, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_183random_sampling}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_184random_sampling(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_samples = 0; PyObject *__pyx_v_replace = 0; PyObject *__pyx_v_random_state = 0; PyObject *__pyx_v_shuffle = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("random_sampling (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_samples,&__pyx_n_s_replace,&__pyx_n_s_random_state,&__pyx_n_s_shuffle,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_183random_sampling(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_samples, PyObject *__pyx_v_replace, PyObject *__pyx_v_random_state, PyObject *__pyx_v_shuffle) { PyObject *__pyx_v_n = NULL; int __pyx_v_is_percent; PyObject *__pyx_v_orig = NULL; PyObject *__pyx_v_dlen = NULL; PyObject *__pyx_v_idx = NULL; PyObject *__pyx_9genexpr56__pyx_v_i = NULL; PyObject *__pyx_9genexpr57__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__233) __Pyx_TraceCall("random_sampling", __pyx_f[0], 5640, 0, __PYX_ERR(0, 5640, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_d); __Pyx_INCREF(__pyx_v_samples); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils.random_sampling", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_v_orig); __Pyx_XDECREF(__pyx_v_dlen); __Pyx_XDECREF(__pyx_v_idx); __Pyx_XDECREF(__pyx_9genexpr56__pyx_v_i); __Pyx_XDECREF(__pyx_9genexpr57__pyx_v_i); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_samples); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__484 = PyTuple_Pack(12, __pyx_n_s_d_3, __pyx_n_s_samples, __pyx_n_s_replace, __pyx_n_s_random_state, __pyx_n_s_shuffle, __pyx_n_s_n, __pyx_n_s_is_percent, __pyx_n_s_orig, __pyx_n_s_dlen, __pyx_n_s_idx, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__484)) __PYX_ERR(0, 5640, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__484); __Pyx_GIVEREF(__pyx_tuple__484); __pyx_codeobj__233 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__484, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_random_sampling, 5640, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__233)) __PYX_ERR(0, 5640, __pyx_L1_error) /* … */ __Pyx_TraceLine(5640,0,__PYX_ERR(0, 5640, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_samples, __pyx_n_s_int) < 0) __PYX_ERR(0, 5640, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_replace, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5640, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_random_state, __pyx_n_s_int) < 0) __PYX_ERR(0, 5640, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_184random_sampling, 0, __pyx_n_s_random_sampling, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__233)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5640, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__485); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_random_sampling, __pyx_t_5) < 0) __PYX_ERR(0, 5640, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__485 = PyTuple_Pack(4, Py_None, ((PyObject *)Py_False), Py_None, ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__485)) __PYX_ERR(0, 5640, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__485); __Pyx_GIVEREF(__pyx_tuple__485);
5641: d,
+5642: samples:int = None ,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+5643: replace:bool = False ,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+5644: random_state:int = None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+5645: shuffle=True,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5640, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_samples); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5640, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_replace); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5640, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_random_state); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5640, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shuffle); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5640, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "random_sampling") < 0)) __PYX_ERR(0, 5640, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_d = values[0]; __pyx_v_samples = ((PyObject*)values[1]); __pyx_v_replace = values[2]; __pyx_v_random_state = ((PyObject*)values[3]); __pyx_v_shuffle = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("random_sampling", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 5640, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.random_sampling", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samples), (&PyInt_Type), 1, "samples", 1))) __PYX_ERR(0, 5642, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_random_state), (&PyInt_Type), 1, "random_state", 1))) __PYX_ERR(0, 5644, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_183random_sampling(__pyx_self, __pyx_v_d, __pyx_v_samples, __pyx_v_replace, __pyx_v_random_state, __pyx_v_shuffle);
5646: ):
5647: """ Sampling data.
5648:
5649: Parameters
5650: ----------
5651: d: {array-like, sparse matrix} of shape (n_samples, n_features)
5652: Data for sampling, where `n_samples` is the number of samples and
5653: `n_features` is the number of features.
5654: samples: int,optional
5655: Ratio or number of items from axis to return.
5656: Default = 1 if `samples` is ``None``.
5657:
5658: replace: bool, default=False
5659: Allow or disallow sampling of the same row more than once.
5660:
5661: random_state: int, array-like, BitGenerator, np.random.RandomState, \
5662: np.random.Generator, optional
5663: If int, array-like, or BitGenerator, seed for random number generator.
5664: If np.random.RandomState or np.random.Generator, use as given.
5665:
5666: shuffle:bool, default=True
5667: Shuffle the data before sampling
5668:
5669: Returns
5670: ----------
5671: d: {array-like, sparse matrix} of shape (n_samples, n_features)
5672: samples data based on the given samples.
5673:
5674: Examples
5675: ---------
5676: >>> from gofast.tools.coreutils import random_sampling
5677: >>> from gofast.datasets import load_hlogs
5678: >>> data= load_hlogs().frame
5679: >>> random_sampling( data, samples = 7 ).shape
5680: (7, 27)
5681: """
5682:
+5683: n= None ; is_percent = False
__Pyx_TraceLine(5683,0,__PYX_ERR(0, 5683, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_n = Py_None; __pyx_v_is_percent = 0;
+5684: orig= copy.deepcopy(samples )
__Pyx_TraceLine(5684,0,__PYX_ERR(0, 5684, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_samples}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_orig = __pyx_t_1; __pyx_t_1 = 0;
+5685: if not hasattr(d, "__iter__"):
__Pyx_TraceLine(5685,0,__PYX_ERR(0, 5685, __pyx_L1_error)) __pyx_t_5 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_iter); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 5685, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { /* … */ }
+5686: d = is_iterable(d, exclude_string= True, transform =True )
__Pyx_TraceLine(5686,0,__PYX_ERR(0, 5686, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_d)) __PYX_ERR(0, 5686, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 5686, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 5686, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_7); __pyx_t_7 = 0;
5687:
+5688: if (
__Pyx_TraceLine(5688,0,__PYX_ERR(0, 5688, __pyx_L1_error)) if (__pyx_t_6) { /* … */ }
+5689: samples is None
__Pyx_TraceLine(5689,0,__PYX_ERR(0, 5689, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_samples == ((PyObject*)Py_None)); if (!__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L5_bool_binop_done; }
+5690: or str(samples) in ('1', '*')
__Pyx_TraceLine(5690,0,__PYX_ERR(0, 5690, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Str(__pyx_v_samples); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_kp_u_1, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5690, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L7_bool_binop_done; } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_kp_u__36, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5690, __pyx_L1_error) __pyx_t_5 = __pyx_t_8; __pyx_L7_bool_binop_done:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __pyx_t_5; __pyx_t_6 = __pyx_t_8; __pyx_L5_bool_binop_done:;
5691: ):
+5692: samples =1.
__Pyx_TraceLine(5692,0,__PYX_ERR(0, 5692, __pyx_L1_error)) __Pyx_INCREF(__pyx_float_1_); __Pyx_DECREF_SET(__pyx_v_samples, ((PyObject*)__pyx_float_1_));
5693:
+5694: if "%" in str(samples):
__Pyx_TraceLine(5694,0,__PYX_ERR(0, 5694, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Str(__pyx_v_samples); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = (__Pyx_PyUnicode_ContainsTF(__pyx_kp_u__203, __pyx_t_7, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5694, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_6) { /* … */ }
+5695: samples = samples.replace ("%", '')
__Pyx_TraceLine(5695,0,__PYX_ERR(0, 5695, __pyx_L1_error)) __pyx_t_7 = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyInt_Type_replace, __pyx_v_samples, __pyx_kp_u__203, __pyx_kp_u__22); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_7))) __PYX_ERR(0, 5695, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_samples, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
+5696: is_percent=True
__Pyx_TraceLine(5696,0,__PYX_ERR(0, 5696, __pyx_L1_error)) __pyx_v_is_percent = 1;
5697: # assert value for consistency.
+5698: try:
__Pyx_TraceLine(5698,0,__PYX_ERR(0, 5698, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L15_try_end; __pyx_L10_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L12_except_error:; __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11); goto __pyx_L1_error; __pyx_L15_try_end:; }
+5699: samples = float( samples)
__Pyx_TraceLine(5699,0,__PYX_ERR(0, 5699, __pyx_L10_error)) __pyx_t_7 = __Pyx_PyNumber_Float(__pyx_v_samples); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5699, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_7); if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_7)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_7))) __PYX_ERR(0, 5699, __pyx_L10_error) __Pyx_DECREF_SET(__pyx_v_samples, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
+5700: except:
__Pyx_TraceLine(5700,0,__PYX_ERR(0, 5700, __pyx_L12_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.random_sampling", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 5700, __pyx_L12_except_error) __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3);
+5701: raise TypeError("Wrong value for 'samples'. Expect an integer."
__Pyx_TraceLine(5701,0,__PYX_ERR(0, 5701, __pyx_L12_except_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Wrong_value_for_samples_Expect_a, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5701, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5701, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_12, 0, 0, 0); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __PYX_ERR(0, 5701, __pyx_L12_except_error) }
+5702: f" Got {type (orig).__name__!r}")
__Pyx_TraceLine(5702,0,__PYX_ERR(0, 5702, __pyx_L12_except_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_orig)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5702, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_12 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_1), __pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5702, __pyx_L12_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5703:
+5704: if samples <=1 or is_percent:
__Pyx_TraceLine(5704,0,__PYX_ERR(0, 5704, __pyx_L1_error)) __pyx_t_3 = PyObject_RichCompare(__pyx_v_samples, __pyx_int_1, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5704, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5704, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_8) { } else { __pyx_t_6 = __pyx_t_8; goto __pyx_L19_bool_binop_done; } __pyx_t_6 = __pyx_v_is_percent; __pyx_L19_bool_binop_done:; if (__pyx_t_6) { /* … */ goto __pyx_L18; }
+5705: samples = assert_ratio(
__Pyx_TraceLine(5705,0,__PYX_ERR(0, 5705, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_assert_ratio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __Pyx_TraceLine(5706,0,__PYX_ERR(0, 5706, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_samples); __Pyx_GIVEREF(__pyx_v_samples); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_samples)) __PYX_ERR(0, 5705, __pyx_L1_error); /* … */ __Pyx_TraceLine(5705,0,__PYX_ERR(0, 5705, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5705, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_12))||((__pyx_t_12) == Py_None) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_12))) __PYX_ERR(0, 5705, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_samples, ((PyObject*)__pyx_t_12)); __pyx_t_12 = 0;
+5706: samples , bounds = (0, 1), exclude_value= 'use lower bound',
__pyx_t_7 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_bounds, __pyx_tuple__234) < 0) __PYX_ERR(0, 5706, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_exclude_value, __pyx_kp_u_use_lower_bound) < 0) __PYX_ERR(0, 5706, __pyx_L1_error) /* … */ __pyx_tuple__234 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_1); if (unlikely(!__pyx_tuple__234)) __PYX_ERR(0, 5706, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__234); __Pyx_GIVEREF(__pyx_tuple__234);
+5707: in_percent= True )
__Pyx_TraceLine(5707,0,__PYX_ERR(0, 5707, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_in_percent, Py_True) < 0) __PYX_ERR(0, 5706, __pyx_L1_error)
5708:
+5709: n = int ( samples * ( d.shape[0] if scipy.sparse.issparse(d)
__Pyx_TraceLine(5709,0,__PYX_ERR(0, 5709, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_scipy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sparse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_issparse); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_d}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_6) { __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_shape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_12 = __pyx_t_2; __pyx_t_2 = 0; } else { /* … */ __Pyx_TraceLine(5709,0,__PYX_ERR(0, 5709, __pyx_L1_error)) __pyx_t_2 = PyNumber_Multiply(__pyx_v_samples, __pyx_t_12); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5709, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_12); __pyx_t_12 = 0;
+5710: else len(d)))
__Pyx_TraceLine(5710,0,__PYX_ERR(0, 5710, __pyx_L1_error)) __pyx_t_13 = PyObject_Length(__pyx_v_d); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5710, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = __pyx_t_2; __pyx_t_2 = 0; }
5711: else:
5712: # data frame
+5713: n= int(samples)
__Pyx_TraceLine(5713,0,__PYX_ERR(0, 5713, __pyx_L1_error)) /*else*/ { __pyx_t_12 = __Pyx_PyNumber_Int(__pyx_v_samples); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_12); __pyx_t_12 = 0; } __pyx_L18:;
5714:
5715: # reset samples and use number of samples instead
+5716: samples =None
__Pyx_TraceLine(5716,0,__PYX_ERR(0, 5716, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_samples, ((PyObject*)Py_None));
5717: # get the total length of d
+5718: dlen = ( d.shape[0] if scipy.sparse.issparse(d) else len(d))
__Pyx_TraceLine(5718,0,__PYX_ERR(0, 5718, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_scipy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_sparse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_issparse); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_d}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __pyx_t_7; __pyx_t_7 = 0; } else { __pyx_t_13 = PyObject_Length(__pyx_v_d); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5718, __pyx_L1_error) __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5718, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_12 = __pyx_t_7; __pyx_t_7 = 0; } __pyx_v_dlen = __pyx_t_12; __pyx_t_12 = 0;
5719: # if number is greater than the length
5720: # block to the length so to retrieve all
5721: # value no matter the arrangement.
+5722: if n > dlen:
__Pyx_TraceLine(5722,0,__PYX_ERR(0, 5722, __pyx_L1_error)) __pyx_t_12 = PyObject_RichCompare(__pyx_v_n, __pyx_v_dlen, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5722, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5722, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6) { /* … */ }
+5723: n = dlen
__Pyx_TraceLine(5723,0,__PYX_ERR(0, 5723, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_dlen); __Pyx_DECREF_SET(__pyx_v_n, __pyx_v_dlen);
+5724: if hasattr (d, 'columns') or hasattr (d, 'name'):
__Pyx_TraceLine(5724,0,__PYX_ERR(0, 5724, __pyx_L1_error)) __pyx_t_8 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_columns); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 5724, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_6 = __pyx_t_8; goto __pyx_L23_bool_binop_done; } __pyx_t_8 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_name_2); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 5724, __pyx_L1_error) __pyx_t_6 = __pyx_t_8; __pyx_L23_bool_binop_done:; if (__pyx_t_6) { /* … */ }
5725: # data frame
+5726: return d.sample ( n= n , frac=samples , replace = replace ,
__Pyx_TraceLine(5726,0,__PYX_ERR(0, 5726, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); /* … */ __Pyx_TraceLine(5726,0,__PYX_ERR(0, 5726, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_sample); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_n, __pyx_v_n) < 0) __PYX_ERR(0, 5726, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_frac, __pyx_v_samples) < 0) __PYX_ERR(0, 5726, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_replace, __pyx_v_replace) < 0) __PYX_ERR(0, 5726, __pyx_L1_error) /* … */ __Pyx_TraceLine(5726,0,__PYX_ERR(0, 5726, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __pyx_t_3; __pyx_t_3 = 0; } else {
+5727: random_state = random_state
__Pyx_TraceLine(5727,0,__PYX_ERR(0, 5727, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_random_state, __pyx_v_random_state) < 0) __PYX_ERR(0, 5726, __pyx_L1_error)
+5728: ) if shuffle else d.iloc [ :n , ::]
__Pyx_TraceLine(5728,0,__PYX_ERR(0, 5728, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5728, __pyx_L1_error) if (__pyx_t_6) { /* … */ __Pyx_TraceLine(5728,0,__PYX_ERR(0, 5728, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_iloc); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5728, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PySlice_New(Py_None, __pyx_v_n, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5728, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5728, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2)) __PYX_ERR(0, 5728, __pyx_L1_error); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__130)) __PYX_ERR(0, 5728, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5728, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_12 = __pyx_t_2; __pyx_t_2 = 0; } __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0;
5729:
+5730: np.random.seed ( random_state)
__Pyx_TraceLine(5730,0,__PYX_ERR(0, 5730, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_seed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_random_state}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+5731: if scipy.sparse.issparse(d) :
__Pyx_TraceLine(5731,0,__PYX_ERR(0, 5731, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_scipy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sparse); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_issparse); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_d}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5731, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5731, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6) { /* … */ }
+5732: if scipy.sparse.isspmatrix_coo(d):
__Pyx_TraceLine(5732,0,__PYX_ERR(0, 5732, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_scipy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sparse); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_isspmatrix_coo); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_d}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5732, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_6) { /* … */ }
+5733: warnings.warn("coo_matrix does not support indexing. Conversion"
__Pyx_TraceLine(5733,0,__PYX_ERR(0, 5733, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5733, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5733, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_u_coo_matrix_does_not_support_inde}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5733, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
5734: " should be performed in CSR matrix")
+5735: d = d.tocsr()
__Pyx_TraceLine(5735,0,__PYX_ERR(0, 5735, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_tocsr); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5735, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5735, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_12); __pyx_t_12 = 0;
5736:
+5737: return d [ np.random.choice(
__Pyx_TraceLine(5737,0,__PYX_ERR(0, 5737, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); /* … */ __Pyx_TraceLine(5737,0,__PYX_ERR(0, 5737, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_random); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_choice); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(5737,0,__PYX_ERR(0, 5737, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2)) __PYX_ERR(0, 5737, __pyx_L1_error); __Pyx_INCREF(__pyx_v_n); __Pyx_GIVEREF(__pyx_v_n); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_n)) __PYX_ERR(0, 5737, __pyx_L1_error); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(5737,0,__PYX_ERR(0, 5737, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_t_14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5737, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_12 = __pyx_t_2; __pyx_t_2 = 0; } else {
+5738: np.arange(d.shape[0]), n, replace=replace )] if shuffle else d [
__Pyx_TraceLine(5738,0,__PYX_ERR(0, 5738, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5738, __pyx_L1_error) if (__pyx_t_6) { /* … */ __Pyx_TraceLine(5738,0,__PYX_ERR(0, 5738, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arange); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_14 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_14}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } /* … */ __Pyx_TraceLine(5738,0,__PYX_ERR(0, 5738, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_replace, __pyx_v_replace) < 0) __PYX_ERR(0, 5738, __pyx_L1_error) /* … */ __Pyx_TraceLine(5738,0,__PYX_ERR(0, 5738, __pyx_L1_error)) { /* enter inner scope */ /* … */ __Pyx_TraceLine(5738,0,__PYX_ERR(0, 5738, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5738, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __pyx_t_1; __pyx_t_1 = 0; } __pyx_r = __pyx_t_12; __pyx_t_12 = 0; goto __pyx_L0;
+5739: [ i for i in range (n)]]
__Pyx_TraceLine(5739,0,__PYX_ERR(0, 5739, __pyx_L29_error)) __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5739, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_n); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5739, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); if (likely(PyList_CheckExact(__pyx_t_14)) || PyTuple_CheckExact(__pyx_t_14)) { __pyx_t_1 = __pyx_t_14; __Pyx_INCREF(__pyx_t_1); __pyx_t_13 = 0; __pyx_t_15 = NULL; } else { __pyx_t_13 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5739, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5739, __pyx_L29_error) } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5739, __pyx_L29_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_14); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 5739, __pyx_L29_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5739, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5739, __pyx_L29_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_14); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 5739, __pyx_L29_error) #else __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5739, __pyx_L29_error) __Pyx_GOTREF(__pyx_t_14); #endif } } else { __pyx_t_14 = __pyx_t_15(__pyx_t_1); if (unlikely(!__pyx_t_14)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5739, __pyx_L29_error) } break; } __Pyx_GOTREF(__pyx_t_14); } __Pyx_XDECREF_SET(__pyx_9genexpr56__pyx_v_i, __pyx_t_14); __pyx_t_14 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_9genexpr56__pyx_v_i))) __PYX_ERR(0, 5739, __pyx_L29_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr56__pyx_v_i); __pyx_9genexpr56__pyx_v_i = 0; goto __pyx_L33_exit_scope; __pyx_L29_error:; __Pyx_XDECREF(__pyx_9genexpr56__pyx_v_i); __pyx_9genexpr56__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L33_exit_scope:; } /* exit inner scope */
5740:
5741: #d = d[idx ]
5742:
5743: # manage the data
+5744: if not hasattr(d, '__array__'):
__Pyx_TraceLine(5744,0,__PYX_ERR(0, 5744, __pyx_L1_error)) __pyx_t_6 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_array_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5744, __pyx_L1_error) __pyx_t_8 = (!__pyx_t_6); if (__pyx_t_8) { /* … */ }
+5745: d = np.array (d )
__Pyx_TraceLine(5745,0,__PYX_ERR(0, 5745, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_d}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5745, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_12); __pyx_t_12 = 0;
5746:
+5747: idx = np.random.randint( len(d), size = n ) if shuffle else [ i for i in range(n)]
__Pyx_TraceLine(5747,0,__PYX_ERR(0, 5747, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5747, __pyx_L1_error) if (__pyx_t_8) { __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_randint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_13 = PyObject_Length(__pyx_v_d); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5747, __pyx_L1_error) __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_size, __pyx_v_n) < 0) __PYX_ERR(0, 5747, __pyx_L1_error) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_14, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5747, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = __pyx_t_7; __pyx_t_7 = 0; } else { { /* enter inner scope */ __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5747, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_14 = __pyx_t_1; __Pyx_INCREF(__pyx_t_14); __pyx_t_13 = 0; __pyx_t_15 = NULL; } else { __pyx_t_13 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5747, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5747, __pyx_L37_error) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_14))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_14); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5747, __pyx_L37_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_1); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 5747, __pyx_L37_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_14); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5747, __pyx_L37_error) #endif if (__pyx_t_13 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_1); __pyx_t_13++; if (unlikely((0 < 0))) __PYX_ERR(0, 5747, __pyx_L37_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5747, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 5747, __pyx_L37_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr57__pyx_v_i, __pyx_t_1); __pyx_t_1 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_9genexpr57__pyx_v_i))) __PYX_ERR(0, 5747, __pyx_L37_error) } __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_9genexpr57__pyx_v_i); __pyx_9genexpr57__pyx_v_i = 0; goto __pyx_L41_exit_scope; __pyx_L37_error:; __Pyx_XDECREF(__pyx_9genexpr57__pyx_v_i); __pyx_9genexpr57__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L41_exit_scope:; } /* exit inner scope */ __pyx_t_12 = __pyx_t_7; __pyx_t_7 = 0; } __pyx_v_idx = __pyx_t_12; __pyx_t_12 = 0;
+5748: if len(d.shape )==1: d =d[idx ]
__Pyx_TraceLine(5748,0,__PYX_ERR(0, 5748, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_shape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = PyObject_Length(__pyx_t_12); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5748, __pyx_L1_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_8 = (__pyx_t_13 == 1); if (__pyx_t_8) { __pyx_t_12 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_v_idx); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_12); __pyx_t_12 = 0; goto __pyx_L42; }
+5749: else: d = d[idx , :]
__Pyx_TraceLine(5749,0,__PYX_ERR(0, 5749, __pyx_L1_error)) /*else*/ { __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_INCREF(__pyx_v_idx); __Pyx_GIVEREF(__pyx_v_idx); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_v_idx)) __PYX_ERR(0, 5749, __pyx_L1_error); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__130)) __PYX_ERR(0, 5749, __pyx_L1_error); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_t_12); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_7); __pyx_t_7 = 0; } __pyx_L42:;
5750:
+5751: return d
__Pyx_TraceLine(5751,0,__PYX_ERR(0, 5751, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_d); __pyx_r = __pyx_v_d; goto __pyx_L0;
5752:
5753:
+5754: def make_obj_consistent_if (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_186make_obj_consistent_if(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_185make_obj_consistent_if, "Combine default values to item to create default consistent iterable \n objects. \n \n This is valid if the size of item does not fit the number of \n expected iterable objects. \n \n Parameters \n ------------\n item : Any \n Object to construct it default values \n \n default: Any \n Value to hold in the case the items does not match the size of given items \n \n size: int, Optional \n Number of items to return. \n \n from_index: bool, default=True \n make an item size to match the exact size of given items \n \n Returns \n -------\n item: Iterable object that contain default values. \n \n Examples \n ----------\n >>> from gofast.tools.coreutils import make_obj_consistent_if\n >>> from gofast.exlib import SVC, LogisticRegression, XGBClassifier \n >>> classifiers = [\"SVC\", \"LogisticRegression\", \"XGBClassifier\"] \n >>> classifier_names = ['SVC', 'LR'] \n >>> make_obj_consistent_if (classifiers, default = classifier_names ) \n ['SVC', 'LogisticRegression', 'XGBClassifier']\n >>> make_obj_consistent_if (classifier_names, from_index =False )\n ['SVC', 'LR']\n >>> >>> make_obj_consistent_if ( classifier_names, \n default= classifiers, size =3 , \n from_index =False )\n ['SVC', 'LR', 'SVC']\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_186make_obj_consistent_if = {"make_obj_consistent_if", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_186make_obj_consistent_if, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_185make_obj_consistent_if}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_186make_obj_consistent_if(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_item = 0; PyObject *__pyx_v_default = 0; PyObject *__pyx_v_size = 0; PyObject *__pyx_v_from_index = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("make_obj_consistent_if (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_item,&__pyx_n_s_default,&__pyx_n_s_size,&__pyx_n_s_from_index,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_185make_obj_consistent_if(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_item, PyObject *__pyx_v_default, PyObject *__pyx_v_size, PyObject *__pyx_v_from_index) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__235) __Pyx_TraceCall("make_obj_consistent_if", __pyx_f[0], 5754, 0, __PYX_ERR(0, 5754, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_item); __Pyx_INCREF(__pyx_v_default); __Pyx_INCREF(__pyx_v_size); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.make_obj_consistent_if", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_item); __Pyx_XDECREF(__pyx_v_default); __Pyx_XDECREF(__pyx_v_size); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__486 = PyTuple_Pack(4, __pyx_n_s_item, __pyx_n_s_default, __pyx_n_s_size, __pyx_n_s_from_index); if (unlikely(!__pyx_tuple__486)) __PYX_ERR(0, 5754, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__486); __Pyx_GIVEREF(__pyx_tuple__486); __pyx_codeobj__235 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__486, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_make_obj_consistent_if, 5754, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__235)) __PYX_ERR(0, 5754, __pyx_L1_error) /* … */ __Pyx_TraceLine(5754,0,__PYX_ERR(0, 5754, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_from_index, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5754, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_186make_obj_consistent_if, 0, __pyx_n_s_make_obj_consistent_if, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__235)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__487); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_obj_consistent_if, __pyx_t_2) < 0) __PYX_ERR(0, 5754, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_tuple__487 = PyTuple_Pack(4, ((PyObject *)Py_Ellipsis), ((PyObject *)Py_Ellipsis), Py_None, ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__487)) __PYX_ERR(0, 5754, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__487); __Pyx_GIVEREF(__pyx_tuple__487);
+5755: item= ... , default = ..., size =None, from_index: bool =True ):
values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_item); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5754, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_default); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5754, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_size); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5754, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_from_index); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5754, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "make_obj_consistent_if") < 0)) __PYX_ERR(0, 5754, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_item = values[0]; __pyx_v_default = values[1]; __pyx_v_size = values[2]; __pyx_v_from_index = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("make_obj_consistent_if", 0, 0, 4, __pyx_nargs); __PYX_ERR(0, 5754, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.make_obj_consistent_if", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_185make_obj_consistent_if(__pyx_self, __pyx_v_item, __pyx_v_default, __pyx_v_size, __pyx_v_from_index);
5756: """Combine default values to item to create default consistent iterable
5757: objects.
5758:
5759: This is valid if the size of item does not fit the number of
5760: expected iterable objects.
5761:
5762: Parameters
5763: ------------
5764: item : Any
5765: Object to construct it default values
5766:
5767: default: Any
5768: Value to hold in the case the items does not match the size of given items
5769:
5770: size: int, Optional
5771: Number of items to return.
5772:
5773: from_index: bool, default=True
5774: make an item size to match the exact size of given items
5775:
5776: Returns
5777: -------
5778: item: Iterable object that contain default values.
5779:
5780: Examples
5781: ----------
5782: >>> from gofast.tools.coreutils import make_obj_consistent_if
5783: >>> from gofast.exlib import SVC, LogisticRegression, XGBClassifier
5784: >>> classifiers = ["SVC", "LogisticRegression", "XGBClassifier"]
5785: >>> classifier_names = ['SVC', 'LR']
5786: >>> make_obj_consistent_if (classifiers, default = classifier_names )
5787: ['SVC', 'LogisticRegression', 'XGBClassifier']
5788: >>> make_obj_consistent_if (classifier_names, from_index =False )
5789: ['SVC', 'LR']
5790: >>> >>> make_obj_consistent_if ( classifier_names,
5791: default= classifiers, size =3 ,
5792: from_index =False )
5793: ['SVC', 'LR', 'SVC']
5794:
5795: """
+5796: if default==... or None : default =[]
__Pyx_TraceLine(5796,0,__PYX_ERR(0, 5796, __pyx_L1_error)) __pyx_t_2 = PyObject_RichCompare(__pyx_v_default, Py_Ellipsis, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5796, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5796, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_1 = 0; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5796, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_default, __pyx_t_2); __pyx_t_2 = 0; }
5797: # for consistency
+5798: default = list( is_iterable (default, exclude_string =True,
__Pyx_TraceLine(5798,0,__PYX_ERR(0, 5798, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_default); __Pyx_GIVEREF(__pyx_v_default); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_default)) __PYX_ERR(0, 5798, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 5798, __pyx_L1_error) /* … */ __Pyx_TraceLine(5798,0,__PYX_ERR(0, 5798, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PySequence_ListKeepNew(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5798, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_default, __pyx_t_5); __pyx_t_5 = 0;
+5799: transform =True ) )
__Pyx_TraceLine(5799,0,__PYX_ERR(0, 5799, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 5798, __pyx_L1_error)
5800:
+5801: if item not in ( ..., None) :
__Pyx_TraceLine(5801,0,__PYX_ERR(0, 5801, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_item); __pyx_t_5 = __pyx_v_item; __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, Py_Ellipsis, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5801, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5801, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L7_bool_binop_done; } __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5801, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5801, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __pyx_t_3; __pyx_L7_bool_binop_done:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = __pyx_t_1; if (__pyx_t_3) { /* … */ goto __pyx_L6; }
+5802: item = list( is_iterable( item , exclude_string =True ,
__Pyx_TraceLine(5802,0,__PYX_ERR(0, 5802, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_item); __Pyx_GIVEREF(__pyx_v_item); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_item)) __PYX_ERR(0, 5802, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 5802, __pyx_L1_error) /* … */ __Pyx_TraceLine(5802,0,__PYX_ERR(0, 5802, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PySequence_ListKeepNew(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5802, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_4); __pyx_t_4 = 0;
+5803: transform = True ) )
__Pyx_TraceLine(5803,0,__PYX_ERR(0, 5803, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 5802, __pyx_L1_error)
+5804: else: item = []
__Pyx_TraceLine(5804,0,__PYX_ERR(0, 5804, __pyx_L1_error)) /*else*/ { __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5804, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_4); __pyx_t_4 = 0; } __pyx_L6:;
5805:
+5806: item += default[len(item):] if from_index else default
__Pyx_TraceLine(5806,0,__PYX_ERR(0, 5806, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_from_index); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 5806, __pyx_L1_error) if (__pyx_t_3) { __pyx_t_7 = PyObject_Length(__pyx_v_item); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5806, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_GetSlice(__pyx_v_default, __pyx_t_7, 0, NULL, NULL, NULL, 1, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __pyx_t_2; __pyx_t_2 = 0; } else { __Pyx_INCREF(__pyx_v_default); __pyx_t_4 = __pyx_v_default; } __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_item, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5806, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_2); __pyx_t_2 = 0;
5807:
+5808: if size is not None:
__Pyx_TraceLine(5808,0,__PYX_ERR(0, 5808, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_size != Py_None); if (__pyx_t_3) { /* … */ }
+5809: size = int (_assert_all_types(size, int, float,
__Pyx_TraceLine(5809,0,__PYX_ERR(0, 5809, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_size); __Pyx_GIVEREF(__pyx_v_size); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_size)) __PYX_ERR(0, 5809, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyInt_Type)); __Pyx_GIVEREF((PyObject *)(&PyInt_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)(&PyInt_Type)))) __PYX_ERR(0, 5809, __pyx_L1_error); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 5809, __pyx_L1_error); /* … */ __Pyx_TraceLine(5809,0,__PYX_ERR(0, 5809, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5809, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_size, __pyx_t_6); __pyx_t_6 = 0;
+5810: objname = "Item 'size'") )
__Pyx_TraceLine(5810,0,__PYX_ERR(0, 5810, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5810, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_objname, __pyx_kp_u_Item_size) < 0) __PYX_ERR(0, 5810, __pyx_L1_error)
+5811: item = item [:size]
__Pyx_TraceLine(5811,0,__PYX_ERR(0, 5811, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_item, 0, 0, NULL, &__pyx_v_size, NULL, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5811, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_6); __pyx_t_6 = 0;
5812:
+5813: return item
__Pyx_TraceLine(5813,0,__PYX_ERR(0, 5813, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_item); __pyx_r = __pyx_v_item; goto __pyx_L0;
5814:
+5815: def replace_data(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_330__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 5815, 0, __PYX_ERR(0, 5815, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(5823,0,__PYX_ERR(0, 5823, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5815, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None)) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_n);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_n);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_n)) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_axis);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_axis);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self)->__pyx_arg_axis)) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)Py_False))) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)Py_False))) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)Py_False))) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 6, ((PyObject *)Py_False))) __PYX_ERR(0, 5815, __pyx_L1_error);
/* … */
__Pyx_TraceLine(5815,0,__PYX_ERR(0, 5815, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5815, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 5815, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 5815, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_188replace_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_187replace_data, "\n Duplicates the data `n` times along a specified axis and applies various \n optional transformations to augment the data suitability for further \n processing or analysis.\n\n Parameters\n ----------\n X : Union[np.ndarray, pd.DataFrame]\n The input data to process. Sparse matrices are not supported.\n y : Optional[Union[np.ndarray, pd.Series]], optional\n Additional target data to process alongside `X`. Default is None.\n n : int, optional\n The number of times to replicate the data. Default is 1.\n axis : int, optional\n The axis along which to concatenate the data. Default is 0.\n reset_index : bool, optional\n If True and `X` is a DataFrame, resets the index without adding\n the old index as a column. Default is False.\n include_original : bool, optional\n If True, the original data is included in the output alongside\n the replicated data. Default is False.\n random_sample : bool, optional\n If True, samples from `X` randomly with replacement. Default is False.\n shuffle : bool, optional\n If True, shuffles the concatenated data. Default is False.\n\n Returns\n -------\n Union[np.ndarray, pd.DataFrame, Tuple[Union[np.ndarray, pd.DataFrame], \n Union[np.ndarray, pd.Series]]]\n The augmented data, either as a single array or DataFrame, or as a tuple\n of arrays/DataFrames if `y` is provided.\n\n Notes\n -----\n The replacement is mathematically formulated as follows:\n Let :math:`X` be a dataset with :math:`m` elements. The function replicates \n :math:`X` `n` times, resulting in a new dataset :math:`X'` of :math:`m * n` \n elements if `include_original` is False. If `include_original` is True,\n :math:`X'` will have :math:`m * (n + 1)` elements.\n\n Examples\n --------\n \n >>> import numpy as np \n >>> from gofast.tools.coreutils import replace_data""\n >>> X, y = np.random.randn ( 7, 2 ), np.arange(7)\n >>> X.shape, y.shape \n ((7, 2), (7,))\n >>> X_new, y_new = replace_data (X, y, n=10 )\n >>> X_new.shape , y_new.shape\n ((70, 2), (70,))\n >>> X = np.array([[1, 2], [3, 4]])\n >>> replace_data(X, n=2, axis=0)\n array([[1, 2],\n [3, 4],\n [1, 2],\n [3, 4]])\n\n >>> import pandas as pd\n >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})\n >>> replace_data(df, n=1, include_original=True, reset_index=True)\n A B\n 0 1 3\n 1 2 4\n 2 1 3\n 3 2 4\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_188replace_data = {"replace_data", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_188replace_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_187replace_data};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_188replace_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_X = 0;
PyObject *__pyx_v_y = 0;
PyObject *__pyx_v_n = 0;
PyObject *__pyx_v_axis = 0;
PyObject *__pyx_v_reset_index = 0;
PyObject *__pyx_v_include_original = 0;
PyObject *__pyx_v_random_sample = 0;
PyObject *__pyx_v_shuffle = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("replace_data (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,&__pyx_n_s_y_4,&__pyx_n_s_n,&__pyx_n_s_axis,&__pyx_n_s_reset_index,&__pyx_n_s_include_original,&__pyx_n_s_random_sample,&__pyx_n_s_shuffle,0};
PyObject* values[8] = {0,0,0,0,0,0,0,0};
__pyx_defaults12 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_self);
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_187replace_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_X, PyObject *__pyx_v_y, PyObject *__pyx_v_n, PyObject *__pyx_v_axis, PyObject *__pyx_v_reset_index, PyObject *__pyx_v_include_original, PyObject *__pyx_v_random_sample, PyObject *__pyx_v_shuffle) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data *__pyx_cur_scope;
PyObject *__pyx_v_concat_data = 0;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__236)
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 5815, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__Pyx_TraceCall("replace_data", __pyx_f[0], 5815, 0, __PYX_ERR(0, 5815, __pyx_L1_error));
__pyx_cur_scope->__pyx_v_n = __pyx_v_n;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_n);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_n);
__pyx_cur_scope->__pyx_v_axis = __pyx_v_axis;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_axis);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_axis);
__pyx_cur_scope->__pyx_v_reset_index = __pyx_v_reset_index;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_reset_index);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_reset_index);
__pyx_cur_scope->__pyx_v_include_original = __pyx_v_include_original;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_include_original);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_include_original);
__pyx_cur_scope->__pyx_v_random_sample = __pyx_v_random_sample;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_random_sample);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_random_sample);
__pyx_cur_scope->__pyx_v_shuffle = __pyx_v_shuffle;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_shuffle);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_shuffle);
__Pyx_INCREF(__pyx_v_X);
__Pyx_INCREF(__pyx_v_y);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.replace_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_concat_data);
__Pyx_XDECREF(__pyx_v_X);
__Pyx_XDECREF(__pyx_v_y);
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__488 = PyTuple_Pack(10, __pyx_n_s_X, __pyx_n_s_y_4, __pyx_n_s_n, __pyx_n_s_axis, __pyx_n_s_reset_index, __pyx_n_s_include_original, __pyx_n_s_random_sample, __pyx_n_s_shuffle, __pyx_n_s_concat_data, __pyx_n_s_concat_data); if (unlikely(!__pyx_tuple__488)) __PYX_ERR(0, 5815, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__488);
__Pyx_GIVEREF(__pyx_tuple__488);
/* … */
__Pyx_TraceLine(5815,0,__PYX_ERR(0, 5815, __pyx_L1_error))
__pyx_t_2 = __Pyx_PyDict_NewPresized(9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5815, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_X, __pyx_kp_s_Union_ArrayLike_DataFrame) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_y_4, __pyx_kp_s_Union_ArrayLike_Series) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_n, __pyx_n_s_int) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_axis, __pyx_n_s_int) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_reset_index, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_include_original, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_random_sample, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_shuffle, __pyx_n_s_bool) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Union_ArrayLike_DataFrame_Tuple) < 0) __PYX_ERR(0, 5815, __pyx_L1_error)
__pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_188replace_data, 0, __pyx_n_s_replace_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__236)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5815, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_5, sizeof(__pyx_defaults12), 2)) __PYX_ERR(0, 5815, __pyx_L1_error)
__pyx_codeobj__236 = (PyObject*)__Pyx_PyCode_New(8, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__488, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_replace_data, 5815, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__236)) __PYX_ERR(0, 5815, __pyx_L1_error)
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data {
PyObject_HEAD
PyObject *__pyx_v_axis;
PyObject *__pyx_v_include_original;
PyObject *__pyx_v_n;
PyObject *__pyx_v_random_sample;
PyObject *__pyx_v_reset_index;
PyObject *__pyx_v_shuffle;
};
5816: X:Union [ArrayLike, DataFrame],
+5817: y: Union [ArrayLike, Series] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_n); values[3] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_axis); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_X)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_y_4); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_axis); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_reset_index); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_include_original); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_random_sample); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shuffle); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5815, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "replace_data") < 0)) __PYX_ERR(0, 5815, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_X = values[0]; __pyx_v_y = values[1]; __pyx_v_n = ((PyObject*)values[2]); __pyx_v_axis = ((PyObject*)values[3]); __pyx_v_reset_index = values[4]; __pyx_v_include_original = values[5]; __pyx_v_random_sample = values[6]; __pyx_v_shuffle = values[7]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("replace_data", 0, 1, 8, __pyx_nargs); __PYX_ERR(0, 5815, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.replace_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_n), (&PyInt_Type), 0, "n", 1))) __PYX_ERR(0, 5818, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_axis), (&PyInt_Type), 0, "axis", 1))) __PYX_ERR(0, 5819, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_187replace_data(__pyx_self, __pyx_v_X, __pyx_v_y, __pyx_v_n, __pyx_v_axis, __pyx_v_reset_index, __pyx_v_include_original, __pyx_v_random_sample, __pyx_v_shuffle);
+5818: n: int = 1,
__Pyx_TraceLine(5818,0,__PYX_ERR(0, 5818, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_1)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_1))) __PYX_ERR(0, 5818, __pyx_L1_error) __Pyx_INCREF(__pyx_int_1); __Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_t_5)->__pyx_arg_n = ((PyObject*)__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1);
+5819: axis: int = 0,
__Pyx_TraceLine(5819,0,__PYX_ERR(0, 5819, __pyx_L1_error)) if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_0)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_0))) __PYX_ERR(0, 5819, __pyx_L1_error) __Pyx_INCREF(__pyx_int_0); __Pyx_CyFunction_Defaults(__pyx_defaults12, __pyx_t_5)->__pyx_arg_axis = ((PyObject*)__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_5, __pyx_pf_6gofast_5tools_9coreutils_330__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_replace_data, __pyx_t_5) < 0) __PYX_ERR(0, 5815, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5820: reset_index: bool = False,
5821: include_original: bool = False,
5822: random_sample: bool = False,
5823: shuffle: bool = False
5824: ) -> Union [ ArrayLike, DataFrame , Tuple[ArrayLike , DataFrame, ArrayLike, Series]]:
5825: """
5826: Duplicates the data `n` times along a specified axis and applies various
5827: optional transformations to augment the data suitability for further
5828: processing or analysis.
5829:
5830: Parameters
5831: ----------
5832: X : Union[np.ndarray, pd.DataFrame]
5833: The input data to process. Sparse matrices are not supported.
5834: y : Optional[Union[np.ndarray, pd.Series]], optional
5835: Additional target data to process alongside `X`. Default is None.
5836: n : int, optional
5837: The number of times to replicate the data. Default is 1.
5838: axis : int, optional
5839: The axis along which to concatenate the data. Default is 0.
5840: reset_index : bool, optional
5841: If True and `X` is a DataFrame, resets the index without adding
5842: the old index as a column. Default is False.
5843: include_original : bool, optional
5844: If True, the original data is included in the output alongside
5845: the replicated data. Default is False.
5846: random_sample : bool, optional
5847: If True, samples from `X` randomly with replacement. Default is False.
5848: shuffle : bool, optional
5849: If True, shuffles the concatenated data. Default is False.
5850:
5851: Returns
5852: -------
5853: Union[np.ndarray, pd.DataFrame, Tuple[Union[np.ndarray, pd.DataFrame],
5854: Union[np.ndarray, pd.Series]]]
5855: The augmented data, either as a single array or DataFrame, or as a tuple
5856: of arrays/DataFrames if `y` is provided.
5857:
5858: Notes
5859: -----
5860: The replacement is mathematically formulated as follows:
5861: Let :math:`X` be a dataset with :math:`m` elements. The function replicates
5862: :math:`X` `n` times, resulting in a new dataset :math:`X'` of :math:`m * n`
5863: elements if `include_original` is False. If `include_original` is True,
5864: :math:`X'` will have :math:`m * (n + 1)` elements.
5865:
5866: Examples
5867: --------
5868:
5869: >>> import numpy as np
5870: >>> from gofast.tools.coreutils import replace_data
5871: >>> X, y = np.random.randn ( 7, 2 ), np.arange(7)
5872: >>> X.shape, y.shape
5873: ((7, 2), (7,))
5874: >>> X_new, y_new = replace_data (X, y, n=10 )
5875: >>> X_new.shape , y_new.shape
5876: ((70, 2), (70,))
5877: >>> X = np.array([[1, 2], [3, 4]])
5878: >>> replace_data(X, n=2, axis=0)
5879: array([[1, 2],
5880: [3, 4],
5881: [1, 2],
5882: [3, 4]])
5883:
5884: >>> import pandas as pd
5885: >>> df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
5886: >>> replace_data(df, n=1, include_original=True, reset_index=True)
5887: A B
5888: 0 1 3
5889: 1 2 4
5890: 2 1 3
5891: 3 2 4
5892: """
+5893: def concat_data(ar: Union[ArrayLike, DataFrame]) -> Union[ArrayLike, DataFrame]:
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_12replace_data_1concat_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_12replace_data_1concat_data = {"concat_data", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_12replace_data_1concat_data, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_12replace_data_1concat_data(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_ar = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("concat_data (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ar,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ar)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5893, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "concat_data") < 0)) __PYX_ERR(0, 5893, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_ar = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("concat_data", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5893, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.replace_data.concat_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_12replace_data_concat_data(__pyx_self, __pyx_v_ar);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_12replace_data_concat_data(PyObject *__pyx_self, PyObject *__pyx_v_ar) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data *__pyx_outer_scope;
PyObject *__pyx_v_repeated_data = NULL;
PyObject *__pyx_v_random_indices = NULL;
PyObject *__pyx_v_concatenated = NULL;
PyObject *__pyx_v_shuffled_indices = NULL;
CYTHON_UNUSED PyObject *__pyx_9genexpr58__pyx_v__ = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_19_replace_data *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("concat_data", __pyx_f[0], 5893, 0, __PYX_ERR(0, 5893, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.replace_data.concat_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_repeated_data);
__Pyx_XDECREF(__pyx_v_random_indices);
__Pyx_XDECREF(__pyx_v_concatenated);
__Pyx_XDECREF(__pyx_v_shuffled_indices);
__Pyx_XDECREF(__pyx_9genexpr58__pyx_v__);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__237 = PyTuple_Pack(6, __pyx_n_s_ar, __pyx_n_s_repeated_data, __pyx_n_s_random_indices, __pyx_n_s_concatenated, __pyx_n_s_shuffled_indices, __pyx_n_s__8); if (unlikely(!__pyx_tuple__237)) __PYX_ERR(0, 5893, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__237);
__Pyx_GIVEREF(__pyx_tuple__237);
/* … */
__Pyx_TraceLine(5893,0,__PYX_ERR(0, 5893, __pyx_L1_error))
__pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5893, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_ar, __pyx_kp_s_Union_ArrayLike_DataFrame) < 0) __PYX_ERR(0, 5893, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_return, __pyx_kp_s_Union_ArrayLike_DataFrame) < 0) __PYX_ERR(0, 5893, __pyx_L1_error)
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_12replace_data_1concat_data, 0, __pyx_n_s_replace_data_locals_concat_data, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__238)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5893, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_1);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_v_concat_data = __pyx_t_2;
__pyx_t_2 = 0;
__pyx_codeobj__238 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__237, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_concat_data, 5893, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__238)) __PYX_ERR(0, 5893, __pyx_L1_error)
+5894: repeated_data = [ar] * (n + 1) if include_original else [ar] * n
__Pyx_TraceLine(5894,0,__PYX_ERR(0, 5894, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_include_original)) { __Pyx_RaiseClosureNameError("include_original"); __PYX_ERR(0, 5894, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_include_original); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 5894, __pyx_L1_error) if (__pyx_t_2) { if (unlikely(!__pyx_cur_scope->__pyx_v_n)) { __Pyx_RaiseClosureNameError("n"); __PYX_ERR(0, 5894, __pyx_L1_error) } __pyx_t_3 = PyNumber_Add(__pyx_cur_scope->__pyx_v_n, __pyx_int_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5894, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5894, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_ar); __Pyx_GIVEREF(__pyx_v_ar); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_ar)) __PYX_ERR(0, 5894, __pyx_L1_error); { PyObject* __pyx_temp = PyNumber_InPlaceMultiply(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_temp)) __PYX_ERR(0, 5894, __pyx_L1_error) __Pyx_GOTREF(__pyx_temp); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = __pyx_temp; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else { if (unlikely(!__pyx_cur_scope->__pyx_v_n)) { __Pyx_RaiseClosureNameError("n"); __PYX_ERR(0, 5894, __pyx_L1_error) } __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5894, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_ar); __Pyx_GIVEREF(__pyx_v_ar); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_ar)) __PYX_ERR(0, 5894, __pyx_L1_error); { PyObject* __pyx_temp = PyNumber_InPlaceMultiply(__pyx_t_4, __pyx_cur_scope->__pyx_v_n); if (unlikely(!__pyx_temp)) __PYX_ERR(0, 5894, __pyx_L1_error) __Pyx_GOTREF(__pyx_temp); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = __pyx_temp; } __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_v_repeated_data = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
5895:
+5896: if random_sample:
__Pyx_TraceLine(5896,0,__PYX_ERR(0, 5896, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_random_sample)) { __Pyx_RaiseClosureNameError("random_sample"); __PYX_ERR(0, 5896, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_random_sample); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 5896, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+5897: random_indices = np.random.choice(
__Pyx_TraceLine(5897,0,__PYX_ERR(0, 5897, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_choice); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(5897,0,__PYX_ERR(0, 5897, __pyx_L1_error)) __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3)) __PYX_ERR(0, 5897, __pyx_L1_error); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5897,0,__PYX_ERR(0, 5897, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_random_indices = __pyx_t_6; __pyx_t_6 = 0;
+5898: ar.shape[0], size=ar.shape[0], replace=True)
__Pyx_TraceLine(5898,0,__PYX_ERR(0, 5898, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(5898,0,__PYX_ERR(0, 5898, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_ar, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5898, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_size, __pyx_t_6) < 0) __PYX_ERR(0, 5898, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_replace, Py_True) < 0) __PYX_ERR(0, 5898, __pyx_L1_error)
+5899: repeated_data = [ar[random_indices] for _ in repeated_data]
__Pyx_TraceLine(5899,0,__PYX_ERR(0, 5899, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5899, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_6); if (unlikely(__pyx_v_repeated_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 5899, __pyx_L6_error) } __pyx_t_3 = __pyx_v_repeated_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5899, __pyx_L6_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 5899, __pyx_L6_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5899, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_XDECREF_SET(__pyx_9genexpr58__pyx_v__, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_ar, __pyx_v_random_indices); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5899, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 5899, __pyx_L6_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr58__pyx_v__); __pyx_9genexpr58__pyx_v__ = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr58__pyx_v__); __pyx_9genexpr58__pyx_v__ = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_repeated_data, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
5900:
+5901: concatenated = pd.concat(repeated_data, axis=axis) if isinstance(
__Pyx_TraceLine(5901,0,__PYX_ERR(0, 5901, __pyx_L1_error)) __pyx_t_2 = PyObject_IsInstance(__pyx_v_ar, __pyx_t_4); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 5901, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_repeated_data); __Pyx_GIVEREF(__pyx_v_repeated_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_repeated_data)) __PYX_ERR(0, 5901, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(!__pyx_cur_scope->__pyx_v_axis)) { __Pyx_RaiseClosureNameError("axis"); __PYX_ERR(0, 5901, __pyx_L1_error) } if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_axis, __pyx_cur_scope->__pyx_v_axis) < 0) __PYX_ERR(0, 5901, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5901, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = __pyx_t_5; __pyx_t_5 = 0; } else {
+5902: ar, pd.DataFrame) else np.concatenate(repeated_data, axis=axis)
__Pyx_TraceLine(5902,0,__PYX_ERR(0, 5902, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5902,0,__PYX_ERR(0, 5902, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_repeated_data); __Pyx_GIVEREF(__pyx_v_repeated_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_repeated_data)) __PYX_ERR(0, 5902, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(!__pyx_cur_scope->__pyx_v_axis)) { __Pyx_RaiseClosureNameError("axis"); __PYX_ERR(0, 5902, __pyx_L1_error) } if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_cur_scope->__pyx_v_axis) < 0) __PYX_ERR(0, 5902, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_6 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_concatenated = __pyx_t_6; __pyx_t_6 = 0;
5903:
+5904: if shuffle:
__Pyx_TraceLine(5904,0,__PYX_ERR(0, 5904, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_shuffle)) { __Pyx_RaiseClosureNameError("shuffle"); __PYX_ERR(0, 5904, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_shuffle); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 5904, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+5905: shuffled_indices = np.random.permutation(concatenated.shape[0])
__Pyx_TraceLine(5905,0,__PYX_ERR(0, 5905, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_random); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_permutation); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_concatenated, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5905, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_shuffled_indices = __pyx_t_6; __pyx_t_6 = 0;
+5906: concatenated = concatenated[shuffled_indices] if isinstance(
__Pyx_TraceLine(5906,0,__PYX_ERR(0, 5906, __pyx_L1_error)) __pyx_t_2 = PyObject_IsInstance(__pyx_v_ar, __pyx_t_5); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 5906, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_2) { __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_concatenated, __pyx_v_shuffled_indices); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5906, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_t_5; __pyx_t_5 = 0; } else {
+5907: ar, pd.DataFrame) else concatenated.iloc[shuffled_indices]
__Pyx_TraceLine(5907,0,__PYX_ERR(0, 5907, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(5907,0,__PYX_ERR(0, 5907, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_concatenated, __pyx_n_s_iloc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_v_shuffled_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5907, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_6 = __pyx_t_3; __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_concatenated, __pyx_t_6); __pyx_t_6 = 0;
5908:
+5909: if reset_index and isinstance(concatenated, pd.DataFrame):
__Pyx_TraceLine(5909,0,__PYX_ERR(0, 5909, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_reset_index)) { __Pyx_RaiseClosureNameError("reset_index"); __PYX_ERR(0, 5909, __pyx_L1_error) } __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_reset_index); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5909, __pyx_L1_error) if (__pyx_t_9) { } else { __pyx_t_2 = __pyx_t_9; goto __pyx_L13_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_9 = PyObject_IsInstance(__pyx_v_concatenated, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 5909, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_9; __pyx_L13_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+5910: concatenated.reset_index(drop=True, inplace=True)
__Pyx_TraceLine(5910,0,__PYX_ERR(0, 5910, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_concatenated, __pyx_n_s_reset_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_drop, Py_True) < 0) __PYX_ERR(0, 5910, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 5910, __pyx_L1_error) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5911:
+5912: return concatenated
__Pyx_TraceLine(5912,0,__PYX_ERR(0, 5912, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_concatenated); __pyx_r = __pyx_v_concatenated; goto __pyx_L0;
5913:
+5914: X = np.array(X) if not isinstance(X, (np.ndarray, pd.DataFrame)) else X
__Pyx_TraceLine(5914,0,__PYX_ERR(0, 5914, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = PyObject_IsInstance(__pyx_v_X, __pyx_t_3); if (!__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L3_bool_binop_done; } __pyx_t_6 = PyObject_IsInstance(__pyx_v_X, __pyx_t_4); __pyx_t_5 = __pyx_t_6; __pyx_L3_bool_binop_done:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (!__pyx_t_5); if (__pyx_t_6) { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_X}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5914, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_X); __pyx_t_2 = __pyx_v_X; } __Pyx_DECREF_SET(__pyx_v_X, __pyx_t_2); __pyx_t_2 = 0;
+5915: y = np.array(y) if y is not None and not isinstance(y, (np.ndarray, pd.Series)) else y
__Pyx_TraceLine(5915,0,__PYX_ERR(0, 5915, __pyx_L1_error)) __pyx_t_5 = (__pyx_v_y != Py_None); if (__pyx_t_5) { } else { __pyx_t_6 = __pyx_t_5; goto __pyx_L5_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = PyObject_IsInstance(__pyx_v_y, __pyx_t_1); if (!__pyx_t_8) { } else { __pyx_t_5 = __pyx_t_8; goto __pyx_L7_bool_binop_done; } __pyx_t_8 = PyObject_IsInstance(__pyx_v_y, __pyx_t_4); __pyx_t_5 = __pyx_t_8; __pyx_L7_bool_binop_done:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = (!__pyx_t_5); __pyx_t_6 = __pyx_t_8; __pyx_L5_bool_binop_done:; if (__pyx_t_6) { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_y}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_2 = __pyx_t_1; __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_v_y); __pyx_t_2 = __pyx_v_y; } __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_2); __pyx_t_2 = 0;
5916:
+5917: if y is not None:
__Pyx_TraceLine(5917,0,__PYX_ERR(0, 5917, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_y != Py_None); if (__pyx_t_6) { /* … */ }
+5918: return concat_data(X), concat_data(y)
__Pyx_TraceLine(5918,0,__PYX_ERR(0, 5918, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __pyx_pf_6gofast_5tools_9coreutils_12replace_data_concat_data(__pyx_v_concat_data, __pyx_v_X); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_12replace_data_concat_data(__pyx_v_concat_data, __pyx_v_y); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5918, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 5918, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1)) __PYX_ERR(0, 5918, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+5919: return concat_data(X)
__Pyx_TraceLine(5919,0,__PYX_ERR(0, 5919, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __pyx_pf_6gofast_5tools_9coreutils_12replace_data_concat_data(__pyx_v_concat_data, __pyx_v_X); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
5920:
+5921: def convert_value_in (v, unit ='m'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_190convert_value_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_189convert_value_in, "Convert value based on the reference unit.\n \n Parameters \n ------------\n v: str, float, int, \n value to convert \n unit: str, default='m'\n Reference unit to convert value in. Default is 'meters'. Could be \n 'kg' or else. \n \n Returns\n -------\n v: float, \n Value converted. \n \n Examples \n ---------\n >>> from gofast.tools.coreutils import convert_value_in \n >>> convert_value_in (20) \n 20.0\n >>> convert_value_in ('20mm') \n 0.02\n >>> convert_value_in ('20kg', unit='g') \n 20000.0\n >>> convert_value_in ('20') \n 20.0\n >>> convert_value_in ('20m', unit='g')\n ValueError: Unknwon unit 'm'...\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_190convert_value_in = {"convert_value_in", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_190convert_value_in, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_189convert_value_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_190convert_value_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_v = 0; PyObject *__pyx_v_unit = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_value_in (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_v,&__pyx_n_s_unit,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_m_2))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_v)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5921, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_unit); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5921, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "convert_value_in") < 0)) __PYX_ERR(0, 5921, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_v = values[0]; __pyx_v_unit = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("convert_value_in", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 5921, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.convert_value_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_189convert_value_in(__pyx_self, __pyx_v_v, __pyx_v_unit); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_189convert_value_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_v, PyObject *__pyx_v_unit) { PyObject *__pyx_v_c = NULL; PyObject *__pyx_v_regex = NULL; PyObject *__pyx_9genexpr59__pyx_v_k = NULL; PyObject *__pyx_9genexpr59__pyx_v_v = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__239) __Pyx_TraceCall("convert_value_in", __pyx_f[0], 5921, 0, __PYX_ERR(0, 5921, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_v); __Pyx_INCREF(__pyx_v_unit); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.convert_value_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_c); __Pyx_XDECREF(__pyx_v_regex); __Pyx_XDECREF(__pyx_9genexpr59__pyx_v_k); __Pyx_XDECREF(__pyx_9genexpr59__pyx_v_v); __Pyx_XDECREF(__pyx_v_v); __Pyx_XDECREF(__pyx_v_unit); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__489 = PyTuple_Pack(6, __pyx_n_s_v, __pyx_n_s_unit, __pyx_n_s_c_2, __pyx_n_s_regex, __pyx_n_s_k, __pyx_n_s_v); if (unlikely(!__pyx_tuple__489)) __PYX_ERR(0, 5921, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__489); __Pyx_GIVEREF(__pyx_tuple__489); __pyx_codeobj__239 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__489, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_convert_value_in, 5921, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__239)) __PYX_ERR(0, 5921, __pyx_L1_error) /* … */ __Pyx_TraceLine(5921,0,__PYX_ERR(0, 5921, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_190convert_value_in, 0, __pyx_n_s_convert_value_in, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__239)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5921, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__490); if (PyDict_SetItem(__pyx_d, __pyx_n_s_convert_value_in, __pyx_t_5) < 0) __PYX_ERR(0, 5921, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__490 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_m_2)); if (unlikely(!__pyx_tuple__490)) __PYX_ERR(0, 5921, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__490); __Pyx_GIVEREF(__pyx_tuple__490);
5922: """Convert value based on the reference unit.
5923:
5924: Parameters
5925: ------------
5926: v: str, float, int,
5927: value to convert
5928: unit: str, default='m'
5929: Reference unit to convert value in. Default is 'meters'. Could be
5930: 'kg' or else.
5931:
5932: Returns
5933: -------
5934: v: float,
5935: Value converted.
5936:
5937: Examples
5938: ---------
5939: >>> from gofast.tools.coreutils import convert_value_in
5940: >>> convert_value_in (20)
5941: 20.0
5942: >>> convert_value_in ('20mm')
5943: 0.02
5944: >>> convert_value_in ('20kg', unit='g')
5945: 20000.0
5946: >>> convert_value_in ('20')
5947: 20.0
5948: >>> convert_value_in ('20m', unit='g')
5949: ValueError: Unknwon unit 'm'...
5950: """
+5951: c= { 'k':1e3 ,
__Pyx_TraceLine(5951,0,__PYX_ERR(0, 5951, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_k, __pyx_float_1e3) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_h, __pyx_float_1e2) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_dc, __pyx_float_1e1) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_kp_u__22, __pyx_float_1e0) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_d_3, __pyx_float_1eneg_1) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_c_2, __pyx_float_1eneg_2) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_m_2, __pyx_float_1eneg_3) < 0) __PYX_ERR(0, 5951, __pyx_L1_error) __pyx_v_c = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
5952: 'h':1e2 ,
5953: 'dc':1e1 ,
5954: '':1e0 ,
5955: 'd':1e-1,
5956: 'c':1e-2 ,
5957: 'm':1e-3
5958: }
+5959: c = {k +str(unit).lower(): v for k, v in c.items() }
__Pyx_TraceLine(5959,0,__PYX_ERR(0, 5959, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_dict_iterator(__pyx_v_c, 1, __pyx_n_s_items, (&__pyx_t_4), (&__pyx_t_5)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_6; __pyx_t_6 = 0; while (1) { __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_4, &__pyx_t_3, &__pyx_t_6, &__pyx_t_7, NULL, __pyx_t_5); if (unlikely(__pyx_t_8 == 0)) break; if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_9genexpr59__pyx_v_k, __pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_9genexpr59__pyx_v_v, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = __Pyx_PyObject_Str(__pyx_v_unit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_lower); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = PyNumber_Add(__pyx_9genexpr59__pyx_v_k, __pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(PyDict_SetItem(__pyx_t_1, (PyObject*)__pyx_t_9, (PyObject*)__pyx_9genexpr59__pyx_v_v))) __PYX_ERR(0, 5959, __pyx_L5_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr59__pyx_v_k); __pyx_9genexpr59__pyx_v_k = 0; __Pyx_XDECREF(__pyx_9genexpr59__pyx_v_v); __pyx_9genexpr59__pyx_v_v = 0; goto __pyx_L8_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_9genexpr59__pyx_v_k); __pyx_9genexpr59__pyx_v_k = 0; __Pyx_XDECREF(__pyx_9genexpr59__pyx_v_v); __pyx_9genexpr59__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L8_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_c, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
5960:
+5961: v = str(v).lower()
__Pyx_TraceLine(5961,0,__PYX_ERR(0, 5961, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5961, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_1); __pyx_t_1 = 0;
5962:
+5963: regex = re.findall(r'[a-zA-Z]', v)
__Pyx_TraceLine(5963,0,__PYX_ERR(0, 5963, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_re); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5963, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_findall); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5963, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_kp_u_a_zA_Z, __pyx_v_v}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5963, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_regex = __pyx_t_1; __pyx_t_1 = 0;
5964:
+5965: if len(regex) !=0:
__Pyx_TraceLine(5965,0,__PYX_ERR(0, 5965, __pyx_L1_error)) __pyx_t_4 = PyObject_Length(__pyx_v_regex); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5965, __pyx_L1_error) __pyx_t_10 = (__pyx_t_4 != 0); if (__pyx_t_10) { /* … */ }
+5966: unit = ''.join( regex )
__Pyx_TraceLine(5966,0,__PYX_ERR(0, 5966, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__22, __pyx_v_regex); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5966, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_unit, __pyx_t_1); __pyx_t_1 = 0;
+5967: v = v.replace (unit, '')
__Pyx_TraceLine(5967,0,__PYX_ERR(0, 5967, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_v, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_v_unit, __pyx_kp_u__22}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_v, __pyx_t_1); __pyx_t_1 = 0;
5968:
+5969: if unit not in c.keys():
__Pyx_TraceLine(5969,0,__PYX_ERR(0, 5969, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_Keys(__pyx_v_c); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5969, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = (__Pyx_PySequence_ContainsTF(__pyx_v_unit, __pyx_t_1, Py_NE)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5969, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_10)) { /* … */ }
+5970: raise ValueError (
__Pyx_TraceLine(5970,0,__PYX_ERR(0, 5970, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5970, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 5970, __pyx_L1_error)
+5971: f"Unknwon unit {unit!r}. Expect {smart_format(c.keys(), 'or' )}."
__Pyx_TraceLine(5971,0,__PYX_ERR(0, 5971, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_11 = 127; __Pyx_INCREF(__pyx_kp_u_Unknwon_unit); __pyx_t_4 += 13; __Pyx_GIVEREF(__pyx_kp_u_Unknwon_unit); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Unknwon_unit); __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_unit), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_11; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u_Expect); __pyx_t_4 += 9; __Pyx_GIVEREF(__pyx_kp_u_Expect); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Expect); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_7 = __Pyx_PyDict_Keys(__pyx_v_c); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_7, __pyx_n_u_or}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) : __pyx_t_11; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_9); __pyx_t_9 = 0; __Pyx_INCREF(__pyx_kp_u_Or_rename_the_unit_parameter_ma); __pyx_t_4 += 42; __Pyx_GIVEREF(__pyx_kp_u_Or_rename_the_unit_parameter_ma); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_Or_rename_the_unit_parameter_ma); /* … */ __Pyx_TraceLine(5971,0,__PYX_ERR(0, 5971, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_1, 7, __pyx_t_4, __pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5971, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+5972: f" Or rename the `unit` parameter maybe to {unit[-1]!r}.")
__Pyx_TraceLine(5972,0,__PYX_ERR(0, 5972, __pyx_L1_error)) __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_unit, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_9), __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5972, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_11 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_11) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_11; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_kp_u__26);
5973:
+5974: return float ( v) * (c.get(unit) or 1e0)
__Pyx_TraceLine(5974,0,__PYX_ERR(0, 5974, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Float(__pyx_v_v); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = __Pyx_PyDict_GetItemDefault(__pyx_v_c, __pyx_v_unit, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5974, __pyx_L1_error) if (!__pyx_t_10) { __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } else { __Pyx_INCREF(__pyx_t_9); __pyx_t_2 = __pyx_t_9; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L11_bool_binop_done; } __pyx_t_9 = PyFloat_FromDouble(1e0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __pyx_t_9; __pyx_t_9 = 0; __pyx_L11_bool_binop_done:; __pyx_t_9 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5974, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L0;
5975:
+5976: def split_list(lst:List[Any], val:int, fill_value:Optional[Any]=None ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_192split_list(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_191split_list, "Module to extract a slice of elements from the list \n \n Parameters \n ------------\n lst: list, \n List composed of item elements \n val: int, \n Number of item to group by default. \n \n Returns \n --------\n group with slide items \n \n Examples\n --------\n >>> from gofast.tools.coreutils import split_list\n >>> lst = [1, 2, 3, 4, 5, 6, 7, 8]\n >>> val = 3\n >>> print(split_list(lst, val))\n [[1, 2, 3], [4, 5, 6], [7, 8]]\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_192split_list = {"split_list", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_192split_list, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_191split_list}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_192split_list(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_lst = 0; PyObject *__pyx_v_val = 0; PyObject *__pyx_v_fill_value = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("split_list (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_lst,&__pyx_n_s_val,&__pyx_n_s_fill_value,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_lst)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5976, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_val)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5976, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("split_list", 0, 2, 3, 1); __PYX_ERR(0, 5976, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_fill_value); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 5976, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "split_list") < 0)) __PYX_ERR(0, 5976, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_lst = values[0]; __pyx_v_val = ((PyObject*)values[1]); __pyx_v_fill_value = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("split_list", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 5976, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.split_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_val), (&PyInt_Type), 0, "val", 1))) __PYX_ERR(0, 5976, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_191split_list(__pyx_self, __pyx_v_lst, __pyx_v_val, __pyx_v_fill_value); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_191split_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_lst, PyObject *__pyx_v_val, PyObject *__pyx_v_fill_value) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list *__pyx_cur_scope; PyObject *__pyx_v_sl = NULL; CYTHON_UNUSED PyObject *__pyx_9genexpr60__pyx_v_key = NULL; PyObject *__pyx_9genexpr60__pyx_v_group = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__240) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 5976, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("split_list", __pyx_f[0], 5976, 0, __PYX_ERR(0, 5976, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_val = __pyx_v_val; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_val); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_val); __Pyx_INCREF(__pyx_v_lst); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils.split_list", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_sl); __Pyx_XDECREF(__pyx_9genexpr60__pyx_v_key); __Pyx_XDECREF(__pyx_9genexpr60__pyx_v_group); __Pyx_XDECREF(__pyx_v_lst); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__491 = PyTuple_Pack(6, __pyx_n_s_lst, __pyx_n_s_val, __pyx_n_s_fill_value, __pyx_n_s_sl, __pyx_n_s_key, __pyx_n_s_group); if (unlikely(!__pyx_tuple__491)) __PYX_ERR(0, 5976, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__491); __Pyx_GIVEREF(__pyx_tuple__491); /* … */ __Pyx_TraceLine(5976,0,__PYX_ERR(0, 5976, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5976, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_lst, __pyx_kp_s_List_Any) < 0) __PYX_ERR(0, 5976, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_val, __pyx_n_s_int) < 0) __PYX_ERR(0, 5976, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_fill_value, __pyx_kp_s_Optional_Any) < 0) __PYX_ERR(0, 5976, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_192split_list, 0, __pyx_n_s_split_list, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__240)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5976, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__62); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_list, __pyx_t_2) < 0) __PYX_ERR(0, 5976, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__240 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__491, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_split_list, 5976, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__240)) __PYX_ERR(0, 5976, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list { PyObject_HEAD PyObject *__pyx_v_val; };
5977: """Module to extract a slice of elements from the list
5978:
5979: Parameters
5980: ------------
5981: lst: list,
5982: List composed of item elements
5983: val: int,
5984: Number of item to group by default.
5985:
5986: Returns
5987: --------
5988: group with slide items
5989:
5990: Examples
5991: --------
5992: >>> from gofast.tools.coreutils import split_list
5993: >>> lst = [1, 2, 3, 4, 5, 6, 7, 8]
5994: >>> val = 3
5995: >>> print(split_list(lst, val))
5996: [[1, 2, 3], [4, 5, 6], [7, 8]]
5997:
5998: """
5999:
+6000: lst = is_iterable(lst , exclude_string =True , transform =True )
__Pyx_TraceLine(6000,0,__PYX_ERR(0, 6000, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_lst); __Pyx_GIVEREF(__pyx_v_lst); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_lst)) __PYX_ERR(0, 6000, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 6000, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 6000, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6000, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_lst, __pyx_t_4); __pyx_t_4 = 0;
+6001: val = int ( _assert_all_types(val, int, float ))
__Pyx_TraceLine(6001,0,__PYX_ERR(0, 6001, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_val, ((PyObject *)(&PyInt_Type)), ((PyObject *)(&PyFloat_Type))}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 3+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_3)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_3))) __PYX_ERR(0, 6001, __pyx_L1_error) __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_val); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_val, ((PyObject*)__pyx_t_3)); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
+6002: try:
__Pyx_TraceLine(6002,0,__PYX_ERR(0, 6002, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L8_try_end:; }
+6003: sl= [list(group) for key, group in itertools.groupby(
__Pyx_TraceLine(6003,0,__PYX_ERR(0, 6003, __pyx_L3_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_itertools); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_groupby); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(6003,0,__PYX_ERR(0, 6003, __pyx_L11_error)) if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6003, __pyx_L11_error) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6003, __pyx_L11_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6003, __pyx_L11_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6003, __pyx_L11_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_4); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6003, __pyx_L11_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6003, __pyx_L11_error) } break; } __Pyx_GOTREF(__pyx_t_4); } if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 6003, __pyx_L11_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_9 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_9); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_9); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); index = 0; __pyx_t_2 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_2)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_9 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_9)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_9); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) __PYX_ERR(0, 6003, __pyx_L11_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L15_unpacking_done; __pyx_L14_unpacking_failed:; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 6003, __pyx_L11_error) __pyx_L15_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_9genexpr60__pyx_v_key, __pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF_SET(__pyx_9genexpr60__pyx_v_group, __pyx_t_9); __pyx_t_9 = 0; __pyx_t_4 = PySequence_List(__pyx_9genexpr60__pyx_v_group); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_4); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 6003, __pyx_L11_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_9genexpr60__pyx_v_group); __pyx_9genexpr60__pyx_v_group = 0; __Pyx_XDECREF(__pyx_9genexpr60__pyx_v_key); __pyx_9genexpr60__pyx_v_key = 0; goto __pyx_L17_exit_scope; __pyx_L11_error:; __Pyx_XDECREF(__pyx_9genexpr60__pyx_v_group); __pyx_9genexpr60__pyx_v_group = 0; __Pyx_XDECREF(__pyx_9genexpr60__pyx_v_key); __pyx_9genexpr60__pyx_v_key = 0; goto __pyx_L3_error; __pyx_L17_exit_scope:; } /* exit inner scope */ __pyx_v_sl = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+6004: lst, lambda x: (x-1)//val)]
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_10split_list_lambda19(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_10split_list_lambda19 = {"lambda19", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_10split_list_lambda19, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_10split_list_lambda19(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_x = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda19 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6004, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda19") < 0)) __PYX_ERR(0, 6004, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_x = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda19", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6004, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.split_list.lambda19", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda19(__pyx_self, __pyx_v_x);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda19(PyObject *__pyx_self, PyObject *__pyx_v_x) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_20_split_list *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda19", __pyx_f[0], 6004, 0, __PYX_ERR(0, 6004, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyInt_SubtractObjC(__pyx_v_x, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6004, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(!__pyx_cur_scope->__pyx_v_val)) { __Pyx_RaiseClosureNameError("val"); __PYX_ERR(0, 6004, __pyx_L1_error) }
__pyx_t_2 = PyNumber_FloorDivide(__pyx_t_1, __pyx_cur_scope->__pyx_v_val); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6004, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.split_list.lambda19", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(6004,0,__PYX_ERR(0, 6004, __pyx_L11_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_10split_list_lambda19, 0, __pyx_n_s_split_list_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6004, __pyx_L11_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_9 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_1))) {
__pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
if (likely(__pyx_t_9)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
__Pyx_INCREF(__pyx_t_9);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_1, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_v_lst, __pyx_t_2};
__pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6003, __pyx_L11_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
+6005: except:
__Pyx_TraceLine(6005,0,__PYX_ERR(0, 6005, __pyx_L5_except_error)) /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.split_list", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 6005, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4);
6006: # when string is given
+6007: sl= list(itertools.zip_longest(
__Pyx_TraceLine(6007,0,__PYX_ERR(0, 6007, __pyx_L5_except_error)) __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_itertools); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6007, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_zip_longest); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6007, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_TraceLine(6007,0,__PYX_ERR(0, 6007, __pyx_L5_except_error)) __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, __pyx_t_9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6007, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PySequence_ListKeepNew(__pyx_t_14); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6007, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF_SET(__pyx_v_sl, ((PyObject*)__pyx_t_9)); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L4_exception_handled; }
+6008: *(iter(lst),)*val,fillvalue =fill_value),)
__Pyx_TraceLine(6008,0,__PYX_ERR(0, 6008, __pyx_L5_except_error)) __pyx_t_9 = PyObject_GetIter(__pyx_v_lst); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6008, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6008, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_GIVEREF(__pyx_t_9); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9)) __PYX_ERR(0, 6008, __pyx_L5_except_error); { PyObject* __pyx_temp = PyNumber_InPlaceMultiply(__pyx_t_12, __pyx_cur_scope->__pyx_v_val); if (unlikely(!__pyx_temp)) __PYX_ERR(0, 6008, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_temp); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = __pyx_temp; } __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6008, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_fillvalue, __pyx_v_fill_value) < 0) __PYX_ERR(0, 6008, __pyx_L5_except_error)
+6009: return sl
__Pyx_TraceLine(6009,0,__PYX_ERR(0, 6009, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_sl); __pyx_r = __pyx_v_sl; goto __pyx_L0;
6010:
+6011: def key_search (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_194key_search(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_193key_search, "Find key in a list of default keys and select the best match. \n \n Parameters \n -----------\n keys: str or list \n The string or a list of key. When multiple keys is passed as a string, \n use the space for key separating. \n \n default_keys: str or list \n The likehood key to find. Can be a litteral text. When a litteral text \n is passed, it is better to provide the regex in order to skip some \n character to parse the text properly. \n \n parse_keys: bool, default=True \n Parse litteral string using default `pattern` and `regex`. \n \n .. versionadded:: 0.2.7 \n \n regex: `re` object, \n Regular expresion object. Regex is important to specify the kind\n of data to parse. the default is:: \n \n >>> import re \n >>> re.compile (r'[_#&*@!_,;\\s-]\\s*', flags=re.IGNORECASE)\n \n pattern: str, default = '[_#&*@!_,;\\s-]\\s*'\n The base pattern to split the text into a columns. Pattern is \n important especially when some character are considers as a part of \n word but they are not a separator. For example a data columns with \n a name `'DH_Azimuth'`, if a pattern is not explicitely provided, \n the default pattern will parse as two separated word which is far \n from the expected results. \n \n deep: bool, default=False \n Not sensistive to uppercase. \n \n raise_exception: bool, default=False \n raise error when key is not find. \n \n Return \n -------\n list: list of valid keys or None if not find ( default) \n\n Examples\n ---------\n >>> from gofast.tools.coreutils import key_search \n >>> key_search('h502-hh2601', default_keys= ['h502', 'h253','HH2601'])\n Out[44]: ['h502']\n >>> key_search('h502-hh2601', default_keys= ['h502', 'h253','HH2601'], \n deep=True)\n Out[46]: ['h502', 'HH2601']""\n >>> key_search('253', default_keys= (\"I m here to find key among h502,\n h253 and HH2601\"))\n Out[53]: ['h253'] \n >>> key_search ('east', default_keys= ['DH_East', 'DH_North'] , deep =True,)\n Out[37]: ['East']\n key_search ('east', default_keys= ['DH_East', 'DH_North'], \n deep =True,parse_keys= False)\n Out[39]: ['DH_East']\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_194key_search = {"key_search", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_194key_search, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_193key_search}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_194key_search(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_keys = 0; PyObject *__pyx_v_default_keys = 0; PyObject *__pyx_v_parse_keys = 0; PyObject *__pyx_v_regex = 0; PyObject *__pyx_v_pattern = 0; PyObject *__pyx_v_deep = 0; PyObject *__pyx_v_raise_exception = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("key_search (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_keys,&__pyx_n_s_default_keys,&__pyx_n_s_parse_keys,&__pyx_n_s_regex,&__pyx_n_s_pattern,&__pyx_n_s_deep,&__pyx_n_s_raise_exception,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_193key_search(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_keys, PyObject *__pyx_v_default_keys, PyObject *__pyx_v_parse_keys, PyObject *__pyx_v_regex, PyObject *__pyx_v_pattern, PyObject *__pyx_v_deep, PyObject *__pyx_v_raise_exception) { PyObject *__pyx_v_kinit = NULL; PyObject *__pyx_v_dk_init = NULL; PyObject *__pyx_v_valid_keys = NULL; Py_UCS4 __pyx_v_key; PyObject *__pyx_v_ii = NULL; PyObject *__pyx_v_dkey = NULL; PyObject *__pyx_v_vk = NULL; PyObject *__pyx_v_kverb = NULL; Py_UCS4 __pyx_9genexpr61__pyx_v_k; PyObject *__pyx_9genexpr62__pyx_v_k = NULL; Py_UCS4 __pyx_9genexpr63__pyx_v_it; PyObject *__pyx_9genexpr64__pyx_v_it = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__241) __Pyx_TraceCall("key_search", __pyx_f[0], 6011, 0, __PYX_ERR(0, 6011, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_keys); __Pyx_INCREF(__pyx_v_default_keys); __Pyx_INCREF(__pyx_v_parse_keys); __Pyx_INCREF(__pyx_v_pattern); __Pyx_INCREF(__pyx_v_deep); __Pyx_INCREF(__pyx_v_raise_exception); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_19); __Pyx_AddTraceback("gofast.tools.coreutils.key_search", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_kinit); __Pyx_XDECREF(__pyx_v_dk_init); __Pyx_XDECREF(__pyx_v_valid_keys); __Pyx_XDECREF(__pyx_v_ii); __Pyx_XDECREF(__pyx_v_dkey); __Pyx_XDECREF(__pyx_v_vk); __Pyx_XDECREF(__pyx_v_kverb); __Pyx_XDECREF(__pyx_9genexpr62__pyx_v_k); __Pyx_XDECREF(__pyx_9genexpr64__pyx_v_it); __Pyx_XDECREF(__pyx_v_keys); __Pyx_XDECREF(__pyx_v_default_keys); __Pyx_XDECREF(__pyx_v_parse_keys); __Pyx_XDECREF(__pyx_v_pattern); __Pyx_XDECREF(__pyx_v_deep); __Pyx_XDECREF(__pyx_v_raise_exception); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__492 = PyTuple_Pack(19, __pyx_n_s_keys, __pyx_n_s_default_keys, __pyx_n_s_parse_keys, __pyx_n_s_regex, __pyx_n_s_pattern, __pyx_n_s_deep, __pyx_n_s_raise_exception, __pyx_n_s_kinit, __pyx_n_s_dk_init, __pyx_n_s_valid_keys, __pyx_n_s_key, __pyx_n_s_ii, __pyx_n_s_dkey, __pyx_n_s_vk, __pyx_n_s_kverb, __pyx_n_s_k, __pyx_n_s_k, __pyx_n_s_it, __pyx_n_s_it); if (unlikely(!__pyx_tuple__492)) __PYX_ERR(0, 6011, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__492); __Pyx_GIVEREF(__pyx_tuple__492); __pyx_codeobj__241 = (PyObject*)__Pyx_PyCode_New(7, 0, 0, 19, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__492, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_key_search, 6011, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__241)) __PYX_ERR(0, 6011, __pyx_L1_error) /* … */ __Pyx_TraceLine(6011,0,__PYX_ERR(0, 6011, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_keys, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_default_keys, __pyx_kp_s_Union_Text_List_str) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parse_keys, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_regex, __pyx_n_s_re) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_deep, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_raise_exception, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_194key_search, 0, __pyx_n_s_key_search, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__241)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6011, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__493); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_key_search, __pyx_t_5) < 0) __PYX_ERR(0, 6011, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__493 = PyTuple_Pack(5, ((PyObject *)Py_True), Py_None, Py_None, ((PyObject *)Py_Ellipsis), ((PyObject *)Py_Ellipsis)); if (unlikely(!__pyx_tuple__493)) __PYX_ERR(0, 6011, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__493); __Pyx_GIVEREF(__pyx_tuple__493);
6012: keys: str,
6013: default_keys: Union [Text , List[str]],
+6014: parse_keys: bool=True,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+6015: regex :re=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+6016: pattern :str=None,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+6017: deep: bool =...,
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis)));
+6018: raise_exception:bool=...,
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_keys)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_default_keys)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("key_search", 0, 2, 7, 1); __PYX_ERR(0, 6011, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_parse_keys); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_exception); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6011, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "key_search") < 0)) __PYX_ERR(0, 6011, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_keys = ((PyObject*)values[0]); __pyx_v_default_keys = values[1]; __pyx_v_parse_keys = values[2]; __pyx_v_regex = values[3]; __pyx_v_pattern = ((PyObject*)values[4]); __pyx_v_deep = values[5]; __pyx_v_raise_exception = values[6]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("key_search", 0, 2, 7, __pyx_nargs); __PYX_ERR(0, 6011, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.key_search", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_keys), (&PyUnicode_Type), 0, "keys", 1))) __PYX_ERR(0, 6012, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern), (&PyUnicode_Type), 1, "pattern", 1))) __PYX_ERR(0, 6016, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_193key_search(__pyx_self, __pyx_v_keys, __pyx_v_default_keys, __pyx_v_parse_keys, __pyx_v_regex, __pyx_v_pattern, __pyx_v_deep, __pyx_v_raise_exception);
6019: ):
6020: """Find key in a list of default keys and select the best match.
6021:
6022: Parameters
6023: -----------
6024: keys: str or list
6025: The string or a list of key. When multiple keys is passed as a string,
6026: use the space for key separating.
6027:
6028: default_keys: str or list
6029: The likehood key to find. Can be a litteral text. When a litteral text
6030: is passed, it is better to provide the regex in order to skip some
6031: character to parse the text properly.
6032:
6033: parse_keys: bool, default=True
6034: Parse litteral string using default `pattern` and `regex`.
6035:
6036: .. versionadded:: 0.2.7
6037:
6038: regex: `re` object,
6039: Regular expresion object. Regex is important to specify the kind
6040: of data to parse. the default is::
6041:
6042: >>> import re
6043: >>> re.compile (r'[_#&*@!_,;\s-]\s*', flags=re.IGNORECASE)
6044:
6045: pattern: str, default = '[_#&*@!_,;\s-]\s*'
6046: The base pattern to split the text into a columns. Pattern is
6047: important especially when some character are considers as a part of
6048: word but they are not a separator. For example a data columns with
6049: a name `'DH_Azimuth'`, if a pattern is not explicitely provided,
6050: the default pattern will parse as two separated word which is far
6051: from the expected results.
6052:
6053: deep: bool, default=False
6054: Not sensistive to uppercase.
6055:
6056: raise_exception: bool, default=False
6057: raise error when key is not find.
6058:
6059: Return
6060: -------
6061: list: list of valid keys or None if not find ( default)
6062:
6063: Examples
6064: ---------
6065: >>> from gofast.tools.coreutils import key_search
6066: >>> key_search('h502-hh2601', default_keys= ['h502', 'h253','HH2601'])
6067: Out[44]: ['h502']
6068: >>> key_search('h502-hh2601', default_keys= ['h502', 'h253','HH2601'],
6069: deep=True)
6070: Out[46]: ['h502', 'HH2601']
6071: >>> key_search('253', default_keys= ("I m here to find key among h502,
6072: h253 and HH2601"))
6073: Out[53]: ['h253']
6074: >>> key_search ('east', default_keys= ['DH_East', 'DH_North'] , deep =True,)
6075: Out[37]: ['East']
6076: key_search ('east', default_keys= ['DH_East', 'DH_North'],
6077: deep =True,parse_keys= False)
6078: Out[39]: ['DH_East']
6079: """
+6080: deep, raise_exception, parse_keys = ellipsis2false(
__Pyx_TraceLine(6080,0,__PYX_ERR(0, 6080, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_ellipsis2false); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(6080,0,__PYX_ERR(0, 6080, __pyx_L1_error)) __Pyx_DECREF_SET(__pyx_v_deep, __pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_raise_exception, __pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_parse_keys, __pyx_t_5); __pyx_t_5 = 0;
+6081: deep, raise_exception, parse_keys)
__Pyx_TraceLine(6081,0,__PYX_ERR(0, 6081, __pyx_L1_error)) __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_v_deep, __pyx_v_raise_exception, __pyx_v_parse_keys}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 3+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 6080, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); __pyx_t_5 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6080, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); index = 0; __pyx_t_2 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 2; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 3) < 0) __PYX_ERR(0, 6080, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L4_unpacking_done; __pyx_L3_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 6080, __pyx_L1_error) __pyx_L4_unpacking_done:; }
6082: # make a copy of original keys
6083:
+6084: kinit = copy.deepcopy(keys)
__Pyx_TraceLine(6084,0,__PYX_ERR(0, 6084, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_keys}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6084, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_kinit = __pyx_t_1; __pyx_t_1 = 0;
+6085: if parse_keys:
__Pyx_TraceLine(6085,0,__PYX_ERR(0, 6085, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_parse_keys); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 6085, __pyx_L1_error) if (__pyx_t_8) { /* … */ goto __pyx_L5; }
+6086: if is_iterable(keys , exclude_string= True ):
__Pyx_TraceLine(6086,0,__PYX_ERR(0, 6086, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_keys); __Pyx_GIVEREF(__pyx_v_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_keys)) __PYX_ERR(0, 6086, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 6086, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6086, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 6086, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_8) { /* … */ }
+6087: keys = ' '.join ( [str(k) for k in keys ])
__Pyx_TraceLine(6087,0,__PYX_ERR(0, 6087, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_keys); __pyx_t_9 = __pyx_v_keys; __pyx_t_13 = __Pyx_init_unicode_iteration(__pyx_t_9, (&__pyx_t_11), (&__pyx_t_12), (&__pyx_t_4)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 6087, __pyx_L1_error) for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_11; __pyx_t_14++) { __pyx_t_10 = __pyx_t_14; __pyx_9genexpr61__pyx_v_k = __Pyx_PyUnicode_READ(__pyx_t_4, __pyx_t_12, __pyx_t_10); __pyx_t_5 = __Pyx_PyUnicode_FromOrdinal(__pyx_9genexpr61__pyx_v_k); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_Str(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 6087, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } /* exit inner scope */ __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__14, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6087, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
6088: # for consisteny checker
+6089: pattern = pattern or '[#&@!_+,;\s-]\s*'
__Pyx_TraceLine(6089,0,__PYX_ERR(0, 6089, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_pattern); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 6089, __pyx_L1_error) if (!__pyx_t_8) { } else { __Pyx_INCREF(__pyx_v_pattern); __pyx_t_3 = __pyx_v_pattern; goto __pyx_L9_bool_binop_done; } __Pyx_INCREF(__pyx_kp_u_s_s_5); __pyx_t_3 = __pyx_kp_u_s_s_5; __pyx_L9_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_pattern, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0;
+6090: keys = str2columns ( keys , regex = regex , pattern = pattern )
__Pyx_TraceLine(6090,0,__PYX_ERR(0, 6090, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_keys); __Pyx_GIVEREF(__pyx_v_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_keys)) __PYX_ERR(0, 6090, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_regex, __pyx_v_regex) < 0) __PYX_ERR(0, 6090, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 6090, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6090, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 6090, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
6091:
+6092: if is_iterable ( default_keys , exclude_string=True ):
__Pyx_TraceLine(6092,0,__PYX_ERR(0, 6092, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_default_keys); __Pyx_GIVEREF(__pyx_v_default_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_default_keys)) __PYX_ERR(0, 6092, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 6092, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6092, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 6092, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_8) { /* … */ }
+6093: default_keys = ' '. join ( [ str(k) for k in default_keys ])
__Pyx_TraceLine(6093,0,__PYX_ERR(0, 6093, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6093, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_v_default_keys)) || PyTuple_CheckExact(__pyx_v_default_keys)) { __pyx_t_2 = __pyx_v_default_keys; __Pyx_INCREF(__pyx_t_2); __pyx_t_11 = 0; __pyx_t_15 = NULL; } else { __pyx_t_11 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_default_keys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6093, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6093, __pyx_L14_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6093, __pyx_L14_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_11); __Pyx_INCREF(__pyx_t_5); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 6093, __pyx_L14_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6093, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6093, __pyx_L14_error) #endif if (__pyx_t_11 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_11); __Pyx_INCREF(__pyx_t_5); __pyx_t_11++; if (unlikely((0 < 0))) __PYX_ERR(0, 6093, __pyx_L14_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6093, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_15(__pyx_t_2); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6093, __pyx_L14_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr62__pyx_v_k, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Str(__pyx_9genexpr62__pyx_v_k); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6093, __pyx_L14_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 6093, __pyx_L14_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr62__pyx_v_k); __pyx_9genexpr62__pyx_v_k = 0; goto __pyx_L18_exit_scope; __pyx_L14_error:; __Pyx_XDECREF(__pyx_9genexpr62__pyx_v_k); __pyx_9genexpr62__pyx_v_k = 0; goto __pyx_L1_error; __pyx_L18_exit_scope:; } /* exit inner scope */ __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__14, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6093, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_default_keys, __pyx_t_2); __pyx_t_2 = 0;
6094: # make a copy
+6095: default_keys = str2columns(
__Pyx_TraceLine(6095,0,__PYX_ERR(0, 6095, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(6096,0,__PYX_ERR(0, 6096, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_default_keys); __Pyx_GIVEREF(__pyx_v_default_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_default_keys)) __PYX_ERR(0, 6095, __pyx_L1_error); /* … */ __Pyx_TraceLine(6095,0,__PYX_ERR(0, 6095, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6095, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_default_keys, __pyx_t_1); __pyx_t_1 = 0;
+6096: default_keys, regex =regex , pattern = pattern )
__pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_regex, __pyx_v_regex) < 0) __PYX_ERR(0, 6096, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pattern, __pyx_v_pattern) < 0) __PYX_ERR(0, 6096, __pyx_L1_error)
6097: else :
+6098: keys = is_iterable(
__Pyx_TraceLine(6098,0,__PYX_ERR(0, 6098, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(6099,0,__PYX_ERR(0, 6099, __pyx_L1_error)) __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_keys); __Pyx_GIVEREF(__pyx_v_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_keys)) __PYX_ERR(0, 6098, __pyx_L1_error); /* … */ __Pyx_TraceLine(6098,0,__PYX_ERR(0, 6098, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_2))) __PYX_ERR(0, 6098, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
+6099: keys, exclude_string = True, transform =True )
__pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6099, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 6099, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 6099, __pyx_L1_error)
+6100: default_keys = is_iterable (
__Pyx_TraceLine(6100,0,__PYX_ERR(0, 6100, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(6101,0,__PYX_ERR(0, 6101, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_default_keys); __Pyx_GIVEREF(__pyx_v_default_keys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_default_keys)) __PYX_ERR(0, 6100, __pyx_L1_error); /* … */ __Pyx_TraceLine(6100,0,__PYX_ERR(0, 6100, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_default_keys, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L5:;
+6101: default_keys, exclude_string=True, transform =True )
__pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 6101, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 6101, __pyx_L1_error)
6102:
+6103: dk_init = copy.deepcopy(default_keys )
__Pyx_TraceLine(6103,0,__PYX_ERR(0, 6103, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_copy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_deepcopy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_default_keys}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_dk_init = __pyx_t_1; __pyx_t_1 = 0;
6104: # if deep convert all keys to lower
+6105: if deep:
__Pyx_TraceLine(6105,0,__PYX_ERR(0, 6105, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_deep); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 6105, __pyx_L1_error) if (__pyx_t_8) { /* … */ }
+6106: keys= [str(it).lower() for it in keys ]
__Pyx_TraceLine(6106,0,__PYX_ERR(0, 6106, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_keys == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); __PYX_ERR(0, 6106, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_keys); __pyx_t_9 = __pyx_v_keys; __pyx_t_13 = __Pyx_init_unicode_iteration(__pyx_t_9, (&__pyx_t_10), (&__pyx_t_12), (&__pyx_t_4)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 6106, __pyx_L1_error) for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_10; __pyx_t_14++) { __pyx_t_11 = __pyx_t_14; __pyx_9genexpr63__pyx_v_it = __Pyx_PyUnicode_READ(__pyx_t_4, __pyx_t_12, __pyx_t_11); __pyx_t_5 = __Pyx_PyUnicode_FromOrdinal(__pyx_9genexpr63__pyx_v_it); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_Str(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_13, 0+__pyx_t_13); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } /* exit inner scope */ if (!(likely(PyUnicode_CheckExact(__pyx_t_1)) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 6106, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_keys, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+6107: default_keys = [str(it).lower() for it in default_keys ]
__Pyx_TraceLine(6107,0,__PYX_ERR(0, 6107, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_1); if (likely(PyList_CheckExact(__pyx_v_default_keys)) || PyTuple_CheckExact(__pyx_v_default_keys)) { __pyx_t_3 = __pyx_v_default_keys; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0; __pyx_t_15 = NULL; } else { __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_default_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6107, __pyx_L24_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6107, __pyx_L24_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6107, __pyx_L24_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6107, __pyx_L24_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6107, __pyx_L24_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_15(__pyx_t_3); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6107, __pyx_L24_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr64__pyx_v_it, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_Str(__pyx_9genexpr64__pyx_v_it); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_lower); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 6107, __pyx_L24_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr64__pyx_v_it); __pyx_9genexpr64__pyx_v_it = 0; goto __pyx_L28_exit_scope; __pyx_L24_error:; __Pyx_XDECREF(__pyx_9genexpr64__pyx_v_it); __pyx_9genexpr64__pyx_v_it = 0; goto __pyx_L1_error; __pyx_L28_exit_scope:; } /* exit inner scope */ __Pyx_DECREF_SET(__pyx_v_default_keys, __pyx_t_1); __pyx_t_1 = 0;
6108:
+6109: valid_keys =[]
__Pyx_TraceLine(6109,0,__PYX_ERR(0, 6109, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_valid_keys = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+6110: for key in keys :
__Pyx_TraceLine(6110,0,__PYX_ERR(0, 6110, __pyx_L1_error)) if (unlikely(__pyx_v_keys == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' is not iterable"); __PYX_ERR(0, 6110, __pyx_L1_error) } __Pyx_INCREF(__pyx_v_keys); __pyx_t_9 = __pyx_v_keys; __pyx_t_13 = __Pyx_init_unicode_iteration(__pyx_t_9, (&__pyx_t_11), (&__pyx_t_12), (&__pyx_t_4)); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 6110, __pyx_L1_error) for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_11; __pyx_t_14++) { __pyx_t_10 = __pyx_t_14; __pyx_v_key = __Pyx_PyUnicode_READ(__pyx_t_4, __pyx_t_12, __pyx_t_10);
+6111: for ii, dkey in enumerate (default_keys) :
__Pyx_TraceLine(6111,0,__PYX_ERR(0, 6111, __pyx_L1_error)) __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_default_keys)) || PyTuple_CheckExact(__pyx_v_default_keys)) { __pyx_t_3 = __pyx_v_default_keys; __Pyx_INCREF(__pyx_t_3); __pyx_t_16 = 0; __pyx_t_15 = NULL; } else { __pyx_t_16 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_default_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6111, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_15)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6111, __pyx_L1_error) #endif if (__pyx_t_16 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_16); __Pyx_INCREF(__pyx_t_5); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 6111, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6111, __pyx_L1_error) #endif if (__pyx_t_16 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_16); __Pyx_INCREF(__pyx_t_5); __pyx_t_16++; if (unlikely((0 < 0))) __PYX_ERR(0, 6111, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_16); __pyx_t_16++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_15(__pyx_t_3); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6111, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_dkey, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_ii, __pyx_t_1); __pyx_t_5 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(6111,0,__PYX_ERR(0, 6111, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L35_for_end; __pyx_L32_break:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L35_for_end; __pyx_L35_for_end:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+6112: vk = re.findall(rf'\w*{key}\w*', dkey)
__Pyx_TraceLine(6112,0,__PYX_ERR(0, 6112, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_re); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_findall); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_17 = 0; __pyx_t_18 = 127; __Pyx_INCREF(__pyx_kp_u_w_2); __pyx_t_17 += 3; __Pyx_GIVEREF(__pyx_kp_u_w_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_w_2); __pyx_t_19 = __Pyx_PyUnicode_FromOrdinal(__pyx_v_key); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_19) : __pyx_t_18; __pyx_t_17 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_19); __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_19); __pyx_t_19 = 0; __Pyx_INCREF(__pyx_kp_u_w_2); __pyx_t_17 += 3; __Pyx_GIVEREF(__pyx_kp_u_w_2); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_w_2); __pyx_t_19 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_17, __pyx_t_18); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_t_19, __pyx_v_dkey}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_13, 2+__pyx_t_13); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_XDECREF_SET(__pyx_v_vk, __pyx_t_5); __pyx_t_5 = 0;
6113: # rather than rf'\b\w*{key}\w*\b'
6114: # if deep take the real values in defaults keys.
+6115: if len(vk) !=0:
__Pyx_TraceLine(6115,0,__PYX_ERR(0, 6115, __pyx_L1_error)) __pyx_t_17 = PyObject_Length(__pyx_v_vk); if (unlikely(__pyx_t_17 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6115, __pyx_L1_error) __pyx_t_8 = (__pyx_t_17 != 0); if (__pyx_t_8) { /* … */ }
+6116: if deep: valid_keys.append( dk_init[ii] )
__Pyx_TraceLine(6116,0,__PYX_ERR(0, 6116, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_deep); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 6116, __pyx_L1_error) if (__pyx_t_8) { __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_dk_init, __pyx_v_ii); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_20 = __Pyx_PyList_Append(__pyx_v_valid_keys, __pyx_t_5); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 6116, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L34; }
+6117: else:valid_keys.extend( vk)
__Pyx_TraceLine(6117,0,__PYX_ERR(0, 6117, __pyx_L1_error)) /*else*/ { __pyx_t_20 = __Pyx_PyList_Extend(__pyx_v_valid_keys, __pyx_v_vk); if (unlikely(__pyx_t_20 == ((int)-1))) __PYX_ERR(0, 6117, __pyx_L1_error) } __pyx_L34:;
+6118: break
__Pyx_TraceLine(6118,0,__PYX_ERR(0, 6118, __pyx_L1_error)) goto __pyx_L32_break;
+6119: if ( raise_exception
__Pyx_TraceLine(6119,0,__PYX_ERR(0, 6119, __pyx_L1_error)) __pyx_t_21 = __Pyx_PyObject_IsTrue(__pyx_v_raise_exception); if (unlikely((__pyx_t_21 < 0))) __PYX_ERR(0, 6119, __pyx_L1_error) if (__pyx_t_21) { } else { __pyx_t_8 = __pyx_t_21; goto __pyx_L37_bool_binop_done; } /* … */ __Pyx_TraceLine(6119,0,__PYX_ERR(0, 6119, __pyx_L1_error)) if (unlikely(__pyx_t_8)) { /* … */ }
+6120: and len(valid_keys)==0
__Pyx_TraceLine(6120,0,__PYX_ERR(0, 6120, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyList_GET_SIZE(__pyx_v_valid_keys); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6120, __pyx_L1_error) __pyx_t_21 = (__pyx_t_11 == 0); __pyx_t_8 = __pyx_t_21; __pyx_L37_bool_binop_done:;
6121: ):
+6122: kverb ='s' if len(kinit)> 1 else ''
__Pyx_TraceLine(6122,0,__PYX_ERR(0, 6122, __pyx_L1_error)) __pyx_t_11 = PyObject_Length(__pyx_v_kinit); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6122, __pyx_L1_error) __pyx_t_8 = (__pyx_t_11 > 1); if (__pyx_t_8) { __Pyx_INCREF(__pyx_n_u_s_2); __pyx_t_1 = __pyx_n_u_s_2; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_1 = __pyx_kp_u__22; } __pyx_v_kverb = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+6123: raise KeyError (f"key{kverb} {kinit!r} not found."
__Pyx_TraceLine(6123,0,__PYX_ERR(0, 6123, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = 0; __pyx_t_18 = 127; __Pyx_INCREF(__pyx_n_u_key); __pyx_t_11 += 3; __Pyx_GIVEREF(__pyx_n_u_key); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_key); __pyx_t_3 = __Pyx_PyUnicode_Unicode(__pyx_v_kverb); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_18; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__14); __pyx_t_11 += 1; __Pyx_GIVEREF(__pyx_kp_u__14); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__14); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_kinit), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_18; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_not_found_Expect); __pyx_t_11 += 19; __Pyx_GIVEREF(__pyx_kp_u_not_found_Expect); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_not_found_Expect); /* … */ __Pyx_TraceLine(6123,0,__PYX_ERR(0, 6123, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 6, __pyx_t_11, __pyx_t_18); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_KeyError, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 6123, __pyx_L1_error)
+6124: f" Expect {smart_format(dk_init, 'or')}")
__Pyx_TraceLine(6124,0,__PYX_ERR(0, 6124, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_dk_init, __pyx_n_u_or}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6124, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_18 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_18) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_18; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_5); __pyx_t_5 = 0;
+6125: return None if len(valid_keys)==0 else valid_keys
__Pyx_TraceLine(6125,0,__PYX_ERR(0, 6125, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_11 = __Pyx_PyList_GET_SIZE(__pyx_v_valid_keys); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6125, __pyx_L1_error) __pyx_t_8 = (__pyx_t_11 == 0); if (__pyx_t_8) { __Pyx_INCREF(Py_None); __pyx_t_1 = Py_None; } else { __Pyx_INCREF(__pyx_v_valid_keys); __pyx_t_1 = __pyx_v_valid_keys; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
6126:
6127: # def repeat_item_insertion(text: str, pos: Union[int, float], item: Optional[str] = None, fill_value: Optional[Any] = None) -> str:
6128: # """ Insert character in text according to its position.
6129: #
6130: # Parameters
6131: # ----------
6132: # text: str
6133: # Text
6134: # pos: Union[int, float]
6135: # Position where the item must be inserted.
6136: # item: Optional[str], default None
6137: # Item to insert at each position.
6138: # fill_value: Optional[Any], default None
6139: # Does nothing special; fill the last position.
6140: # Returns
6141: # --------
6142: # text: str
6143: # New construct object.
6144: #
6145: # Examples
6146: # ----------
6147: # >>> repeat_item_insertion('0125356.45', pos=2, item=':')
6148: # '01:25:35:6.45'
6149: # >>> repeat_item_insertion('Function inserts car in text.', pos=10, item='TK')
6150: # 'Function iTKnserts carTK in text.'
6151: # """
6152: # if item is None:
6153: # item = ''
6154: # # For consistency
6155: # lst = list(str(text))
6156: # # Check whether there is a decimal then remove it
6157: # dec_part = []
6158: # ent_part = lst
6159: # for i, it in enumerate(lst):
6160: # if it == '.':
6161: # ent_part, dec_part = lst[:i], lst[i:]
6162: # break
6163: # # Now split list
6164: # if fill_value is None:
6165: # fill_value = ''
6166: #
6167: # value = split_list(ent_part, val=pos, fill_value=fill_value)
6168: # # Join with mark
6169: # join_lst = [''.join(s) for s in value]
6170: # # Use empty string instead of None in the join operation
6171: # result = str(item).join(join_lst) + ''.join(dec_part)
6172: # return result
6173:
6174:
+6175: def numstr2dms(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_332__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 6175, 0, __PYX_ERR(0, 6175, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(6182,0,__PYX_ERR(0, 6182, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6175, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)Py_True));
__Pyx_GIVEREF(((PyObject *)Py_True));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)Py_True))) __PYX_ERR(0, 6175, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_func);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_func);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_func)) __PYX_ERR(0, 6175, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_empty_tuple));
__Pyx_GIVEREF(((PyObject*)__pyx_empty_tuple));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject*)__pyx_empty_tuple))) __PYX_ERR(0, 6175, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_regex);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_regex);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self)->__pyx_arg_regex)) __PYX_ERR(0, 6175, __pyx_L1_error);
__Pyx_INCREF(((PyObject*)__pyx_kp_u_s_s_6));
__Pyx_GIVEREF(((PyObject*)__pyx_kp_u_s_s_6));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject*)__pyx_kp_u_s_s_6))) __PYX_ERR(0, 6175, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)Py_False))) __PYX_ERR(0, 6175, __pyx_L1_error);
/* … */
__Pyx_TraceLine(6175,0,__PYX_ERR(0, 6175, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6175, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 6175, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 6175, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_196numstr2dms(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_195numstr2dms, " Convert numerical digit string to DD:MM:SS\n \n Note that any string digit for Minutes and seconds must be composed\n of two values i.e., the function accepts at least six digits, otherwise an \n error occurs. For instance, the value between [0-9] must be prefixed by 0 \n beforehand. Here is an example for designating 1 degree-1 min-1 seconds::\n \n sdigit= 1'1'1\" --> 01'01'01 or 010101\n \n where ``010101`` is the right arguments for ``111``. \n \n Parameters\n -----------\n sdigit: str, \n Digit string composing of unique values. \n func: Callable, \n Function uses to parse digit. Function must return string values. \n Any other values should be converted to str.\n \n args: tuple\n Function `func` positional arguments \n \n regex: `re` object, \n Regular expression object. Regex is important to specify the kind\n of data to parse. The default is:: \n \n >>> import re \n >>> re.compile(r'[_#&@!+,;:\"'\\s-]\\s*', flags=re.IGNORECASE) \n \n pattern: str, default = '[_#&@!+,;:\"'\\s-]\\s*'\n Specific pattern for sanitizing sdigit. For instance, remove undesirable \n non-character. \n \n sanitize: bool, default=True \n Remove undesirable characters using the default argument of `pattern`\n parameter. \n \n return_values: bool, default=False, \n Return the DD:MM:SS into a tuple of (DD, MM, SS).\n \n Returns \n -------\n sdigit/tuple: str, tuple \n DD:MM:SS or tuple of (DD, MM, SS)\n \n Examples\n --------\n >>> numstr2dms(\"1134132.08\")\n '113:41:32.08'\n >>> numstr2dms(\"13'41'32.08\")\n '13:41:32.08'\n >>> numstr2dms(\"11:34:13:2.08\", return_values=True)\n (113.0, 41.0, 32.08)\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_196numstr2dms = {"numstr2dms", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_196numstr2dms, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_195numstr2dms};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_196numstr2dms(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_sdigit = 0;
PyObject *__pyx_v_sanitize = 0;
PyObject *__pyx_v_func = 0;
PyObject *__pyx_v_args = 0;
CYTHON_UNUSED PyObject *__pyx_v_regex = 0;
PyObject *__pyx_v_pattern = 0;
PyObject *__pyx_v_return_values = 0;
PyObject *__pyx_v_kws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("numstr2dms (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL;
__Pyx_GOTREF(__pyx_v_kws);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sdigit,&__pyx_n_s_sanitize,&__pyx_n_s_func,&__pyx_n_s_args,&__pyx_n_s_regex,&__pyx_n_s_pattern,&__pyx_n_s_return_values,0};
PyObject* values[7] = {0,0,0,0,0,0,0};
__pyx_defaults13 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_self);
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
values[2] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_func);
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_empty_tuple)));
values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_regex);
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_u_s_s_6)));
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6);
CYTHON_FALLTHROUGH;
case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sdigit)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sanitize);
if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 3:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args);
if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 4:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex);
if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 5:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_pattern);
if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 6:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_values);
if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6175, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, kwd_pos_args, "numstr2dms") < 0)) __PYX_ERR(0, 6175, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6);
CYTHON_FALLTHROUGH;
case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5);
CYTHON_FALLTHROUGH;
case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4);
CYTHON_FALLTHROUGH;
case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3);
CYTHON_FALLTHROUGH;
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_sdigit = ((PyObject*)values[0]);
__pyx_v_sanitize = values[1];
__pyx_v_func = values[2];
__pyx_v_args = ((PyObject*)values[3]);
__pyx_v_regex = values[4];
__pyx_v_pattern = ((PyObject*)values[5]);
__pyx_v_return_values = values[6];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("numstr2dms", 0, 1, 7, __pyx_nargs); __PYX_ERR(0, 6175, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0;
__Pyx_AddTraceback("gofast.tools.coreutils.numstr2dms", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sdigit), (&PyUnicode_Type), 0, "sdigit", 1))) __PYX_ERR(0, 6176, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 0, "args", 1))) __PYX_ERR(0, 6179, __pyx_L1_error)
if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_pattern), (&PyUnicode_Type), 0, "pattern", 1))) __PYX_ERR(0, 6181, __pyx_L1_error)
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_195numstr2dms(__pyx_self, __pyx_v_sdigit, __pyx_v_sanitize, __pyx_v_func, __pyx_v_args, __pyx_v_regex, __pyx_v_pattern, __pyx_v_return_values, __pyx_v_kws);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__pyx_r = NULL;
__pyx_L0:;
__Pyx_DECREF(__pyx_v_kws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_195numstr2dms(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sdigit, PyObject *__pyx_v_sanitize, PyObject *__pyx_v_func, PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_regex, PyObject *__pyx_v_pattern, PyObject *__pyx_v_return_values, PyObject *__pyx_v_kws) {
PyObject *__pyx_v_decimal = NULL;
PyObject *__pyx_v_sdigit_list = NULL;
PyObject *__pyx_v_sec = NULL;
PyObject *__pyx_v_mm = NULL;
PyObject *__pyx_v_deg = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__242)
__Pyx_TraceCall("numstr2dms", __pyx_f[0], 6175, 0, __PYX_ERR(0, 6175, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_sdigit);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.numstr2dms", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_decimal);
__Pyx_XDECREF(__pyx_v_sdigit_list);
__Pyx_XDECREF(__pyx_v_sec);
__Pyx_XDECREF(__pyx_v_mm);
__Pyx_XDECREF(__pyx_v_deg);
__Pyx_XDECREF(__pyx_v_sdigit);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__494 = PyTuple_Pack(13, __pyx_n_s_sdigit, __pyx_n_s_sanitize, __pyx_n_s_func, __pyx_n_s_args, __pyx_n_s_regex, __pyx_n_s_pattern, __pyx_n_s_return_values, __pyx_n_s_kws_2, __pyx_n_s_decimal, __pyx_n_s_sdigit_list, __pyx_n_s_sec, __pyx_n_s_mm, __pyx_n_s_deg); if (unlikely(!__pyx_tuple__494)) __PYX_ERR(0, 6175, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__494);
__Pyx_GIVEREF(__pyx_tuple__494);
/* … */
__Pyx_TraceLine(6175,0,__PYX_ERR(0, 6175, __pyx_L1_error))
__pyx_t_5 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6175, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_sdigit, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_sanitize, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_func, __pyx_n_s_callable) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_n_s_tuple) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_regex, __pyx_kp_s_re_Pattern) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_pattern, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_values, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_Union_str_Tuple_float_float_floa) < 0) __PYX_ERR(0, 6175, __pyx_L1_error)
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_196numstr2dms, 0, __pyx_n_s_numstr2dms, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__242)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6175, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_2, sizeof(__pyx_defaults13), 2)) __PYX_ERR(0, 6175, __pyx_L1_error)
__pyx_codeobj__242 = (PyObject*)__Pyx_PyCode_New(7, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__494, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_numstr2dms, 6175, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__242)) __PYX_ERR(0, 6175, __pyx_L1_error)
6176: sdigit: str,
6177: sanitize: bool = True,
+6178: func: callable = lambda x, *args, **kws: x,
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_305lambda20(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_305lambda20 = {"lambda20", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_305lambda20, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_305lambda20(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_x = 0;
CYTHON_UNUSED PyObject *__pyx_v_args = 0;
CYTHON_UNUSED PyObject *__pyx_v_kws = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda20 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
__pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL;
__Pyx_GOTREF(__pyx_v_kws);
__pyx_v_args = __Pyx_ArgsSlice_FASTCALL(__pyx_args, 1, __pyx_nargs);
if (unlikely(!__pyx_v_args)) {
__Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0;
__Pyx_RefNannyFinishContext();
return NULL;
}
__Pyx_GOTREF(__pyx_v_args);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
default:
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_x)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6178, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
const Py_ssize_t used_pos_args = (kwd_pos_args < 1) ? kwd_pos_args : 1;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, used_pos_args, "lambda20") < 0)) __PYX_ERR(0, 6178, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs < 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_x = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda20", 0, 1, 1, __pyx_nargs); __PYX_ERR(0, 6178, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
__Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0;
__Pyx_AddTraceback("gofast.tools.coreutils.lambda20", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_6gofast_5tools_9coreutils_lambda20(__pyx_self, __pyx_v_x, __pyx_v_args, __pyx_v_kws);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
__Pyx_DECREF(__pyx_v_args);
__Pyx_DECREF(__pyx_v_kws);
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_6gofast_5tools_9coreutils_lambda20(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x, CYTHON_UNUSED PyObject *__pyx_v_args, CYTHON_UNUSED PyObject *__pyx_v_kws) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda20", __pyx_f[0], 6178, 0, __PYX_ERR(0, 6178, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(__pyx_v_x);
__pyx_r = __pyx_v_x;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.lambda20", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(6178,0,__PYX_ERR(0, 6178, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_305lambda20, 0, __pyx_n_s_numstr2dms_locals_lambda, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6178, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_t_2)->__pyx_arg_func = __pyx_t_4;
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
6179: args: tuple = (),
+6180: regex: re.Pattern = re.compile(r'[_#&@!+,;:"\'\s-]\s*', flags=re.IGNORECASE),
__Pyx_TraceLine(6180,0,__PYX_ERR(0, 6180, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_compile); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_re); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_flags, __pyx_t_8) < 0) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__495, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults13, __pyx_t_2)->__pyx_arg_regex = __pyx_t_8; __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_2, __pyx_pf_6gofast_5tools_9coreutils_332__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_numstr2dms, __pyx_t_2) < 0) __PYX_ERR(0, 6175, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__495 = PyTuple_Pack(1, __pyx_kp_u_s_s_7); if (unlikely(!__pyx_tuple__495)) __PYX_ERR(0, 6180, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__495); __Pyx_GIVEREF(__pyx_tuple__495);
6181: pattern: str = '[_#&@!+,;:"\'\s-]\s*',
6182: return_values: bool = False,
6183: **kws
6184: ) -> Union[str, Tuple[float, float, float]]:
6185: """ Convert numerical digit string to DD:MM:SS
6186:
6187: Note that any string digit for Minutes and seconds must be composed
6188: of two values i.e., the function accepts at least six digits, otherwise an
6189: error occurs. For instance, the value between [0-9] must be prefixed by 0
6190: beforehand. Here is an example for designating 1 degree-1 min-1 seconds::
6191:
6192: sdigit= 1'1'1" --> 01'01'01 or 010101
6193:
6194: where ``010101`` is the right arguments for ``111``.
6195:
6196: Parameters
6197: -----------
6198: sdigit: str,
6199: Digit string composing of unique values.
6200: func: Callable,
6201: Function uses to parse digit. Function must return string values.
6202: Any other values should be converted to str.
6203:
6204: args: tuple
6205: Function `func` positional arguments
6206:
6207: regex: `re` object,
6208: Regular expression object. Regex is important to specify the kind
6209: of data to parse. The default is::
6210:
6211: >>> import re
6212: >>> re.compile(r'[_#&@!+,;:"\'\s-]\s*', flags=re.IGNORECASE)
6213:
6214: pattern: str, default = '[_#&@!+,;:"\'\s-]\s*'
6215: Specific pattern for sanitizing sdigit. For instance, remove undesirable
6216: non-character.
6217:
6218: sanitize: bool, default=True
6219: Remove undesirable characters using the default argument of `pattern`
6220: parameter.
6221:
6222: return_values: bool, default=False,
6223: Return the DD:MM:SS into a tuple of (DD, MM, SS).
6224:
6225: Returns
6226: -------
6227: sdigit/tuple: str, tuple
6228: DD:MM:SS or tuple of (DD, MM, SS)
6229:
6230: Examples
6231: --------
6232: >>> numstr2dms("1134132.08")
6233: '113:41:32.08'
6234: >>> numstr2dms("13'41'32.08")
6235: '13:41:32.08'
6236: >>> numstr2dms("11:34:13:2.08", return_values=True)
6237: (113.0, 41.0, 32.08)
6238: """
6239: # Remove any character from the string digit
+6240: sdigit = str(sdigit)
__Pyx_TraceLine(6240,0,__PYX_ERR(0, 6240, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_v_sdigit); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_sdigit, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
6241:
+6242: if sanitize:
__Pyx_TraceLine(6242,0,__PYX_ERR(0, 6242, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_sanitize); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 6242, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+6243: sdigit = re.sub(pattern, "", sdigit, flags=re.IGNORECASE)
__Pyx_TraceLine(6243,0,__PYX_ERR(0, 6243, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_pattern); __Pyx_GIVEREF(__pyx_v_pattern); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_pattern)) __PYX_ERR(0, 6243, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__22); __Pyx_GIVEREF(__pyx_kp_u__22); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__22)) __PYX_ERR(0, 6243, __pyx_L1_error); __Pyx_INCREF(__pyx_v_sdigit); __Pyx_GIVEREF(__pyx_v_sdigit); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_sdigit)) __PYX_ERR(0, 6243, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_re); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_flags, __pyx_t_6) < 0) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_6))) __PYX_ERR(0, 6243, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_sdigit, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
6244:
+6245: try:
__Pyx_TraceLine(6245,0,__PYX_ERR(0, 6245, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9); goto __pyx_L1_error; __pyx_L9_try_end:; }
+6246: float(sdigit)
__Pyx_TraceLine(6246,0,__PYX_ERR(0, 6246, __pyx_L4_error)) if (unlikely(__pyx_v_sdigit == Py_None)) { PyErr_SetString(PyExc_TypeError, "float() argument must be a string or a number, not 'NoneType'"); __PYX_ERR(0, 6246, __pyx_L4_error) } __pyx_t_10 = __Pyx_PyUnicode_AsDouble(__pyx_v_sdigit); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 6246, __pyx_L4_error)
+6247: except ValueError:
__Pyx_TraceLine(6247,0,__PYX_ERR(0, 6247, __pyx_L6_except_error)) __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_11) { __Pyx_AddTraceback("gofast.tools.coreutils.numstr2dms", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_1) < 0) __PYX_ERR(0, 6247, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_1);
+6248: raise ValueError(f"Wrong value. Expects a string-digit or digit. Got {sdigit!r}")
__Pyx_TraceLine(6248,0,__PYX_ERR(0, 6248, __pyx_L6_except_error)) __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_sdigit), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6248, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Wrong_value_Expects_a_string_dig, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6248, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6248, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 6248, __pyx_L6_except_error) } goto __pyx_L6_except_error;
6249:
+6250: if callable(func):
__Pyx_TraceLine(6250,0,__PYX_ERR(0, 6250, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_func); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 6250, __pyx_L1_error) if (__pyx_t_2) { /* … */ }
+6251: sdigit = func(sdigit, *args, **kws)
__Pyx_TraceLine(6251,0,__PYX_ERR(0, 6251, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_sdigit); __Pyx_GIVEREF(__pyx_v_sdigit); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sdigit)) __PYX_ERR(0, 6251, __pyx_L1_error); __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_v_args); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyDict_Copy(__pyx_v_kws); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_Call(__pyx_v_func, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6251, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_6))) __PYX_ERR(0, 6251, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_sdigit, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
6252:
6253: # In the case there is'
+6254: decimal = '0'
__Pyx_TraceLine(6254,0,__PYX_ERR(0, 6254, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_0_4); __pyx_v_decimal = __pyx_kp_u_0_4;
6255: # Remove decimal
+6256: sdigit_list = sdigit.split(".")
__Pyx_TraceLine(6256,0,__PYX_ERR(0, 6256, __pyx_L1_error)) if (unlikely(__pyx_v_sdigit == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "split"); __PYX_ERR(0, 6256, __pyx_L1_error) } __pyx_t_6 = PyUnicode_Split(__pyx_v_sdigit, __Pyx_NoneAsNull(__pyx_kp_u__26), -1L); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6256, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_sdigit_list = __pyx_t_6; __pyx_t_6 = 0;
6257:
+6258: if len(sdigit_list) == 2:
__Pyx_TraceLine(6258,0,__PYX_ERR(0, 6258, __pyx_L1_error)) __pyx_t_12 = PyObject_Length(__pyx_v_sdigit_list); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6258, __pyx_L1_error) __pyx_t_2 = (__pyx_t_12 == 2); if (__pyx_t_2) { /* … */ }
+6259: sdigit, decimal = sdigit_list
__Pyx_TraceLine(6259,0,__PYX_ERR(0, 6259, __pyx_L1_error)) if ((likely(PyTuple_CheckExact(__pyx_v_sdigit_list))) || (PyList_CheckExact(__pyx_v_sdigit_list))) { PyObject* sequence = __pyx_v_sdigit_list; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 6259, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_6 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { Py_ssize_t index = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_sdigit_list); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6259, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); index = 0; __pyx_t_6 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_4), 2) < 0) __PYX_ERR(0, 6259, __pyx_L1_error) __pyx_t_13 = NULL; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L15_unpacking_done; __pyx_L14_unpacking_failed:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_13 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 6259, __pyx_L1_error) __pyx_L15_unpacking_done:; } if (!(likely(PyUnicode_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_6))) __PYX_ERR(0, 6259, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_sdigit, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_decimal, __pyx_t_1); __pyx_t_1 = 0;
6260:
+6261: if len(sdigit) < 6:
__Pyx_TraceLine(6261,0,__PYX_ERR(0, 6261, __pyx_L1_error)) if (unlikely(__pyx_v_sdigit == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 6261, __pyx_L1_error) } __pyx_t_12 = __Pyx_PyUnicode_GET_LENGTH(__pyx_v_sdigit); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6261, __pyx_L1_error) __pyx_t_2 = (__pyx_t_12 < 6); if (unlikely(__pyx_t_2)) { /* … */ }
+6262: raise ValueError(f"DMS expects at least six digits (DD:MM:SS). Got {sdigit!r}")
__Pyx_TraceLine(6262,0,__PYX_ERR(0, 6262, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_sdigit), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_DMS_expects_at_least_six_digits, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6262, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 6262, __pyx_L1_error)
6263:
+6264: sec, sdigit = sdigit[-2:], sdigit[:-2]
__Pyx_TraceLine(6264,0,__PYX_ERR(0, 6264, __pyx_L1_error)) if (unlikely(__pyx_v_sdigit == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 6264, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyUnicode_Substring(__pyx_v_sdigit, -2L, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (unlikely(__pyx_v_sdigit == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 6264, __pyx_L1_error) } __pyx_t_6 = __Pyx_PyUnicode_Substring(__pyx_v_sdigit, 0, -2L); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6264, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_sec = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_sdigit, ((PyObject*)__pyx_t_6)); __pyx_t_6 = 0;
+6265: mm, sdigit = sdigit[-2:], sdigit[:-2]
__Pyx_TraceLine(6265,0,__PYX_ERR(0, 6265, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyUnicode_Substring(__pyx_v_sdigit, -2L, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyUnicode_Substring(__pyx_v_sdigit, 0, -2L); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6265, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mm = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_sdigit, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
+6266: deg = sdigit # The remaining part
__Pyx_TraceLine(6266,0,__PYX_ERR(0, 6266, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_sdigit); __pyx_v_deg = __pyx_v_sdigit;
6267: # Concatenate second decimal
+6268: sec += f".{decimal}"
__Pyx_TraceLine(6268,0,__PYX_ERR(0, 6268, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_decimal, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u__26, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlace(__pyx_v_sec, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6268, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_sec, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
6269:
+6270: return tuple(map(float, [deg, mm, sec])) if return_values \
__Pyx_TraceLine(6270,0,__PYX_ERR(0, 6270, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_return_values); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 6270, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_deg); __Pyx_GIVEREF(__pyx_v_deg); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 0, __pyx_v_deg)) __PYX_ERR(0, 6270, __pyx_L1_error); __Pyx_INCREF(__pyx_v_mm); __Pyx_GIVEREF(__pyx_v_mm); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 1, __pyx_v_mm)) __PYX_ERR(0, 6270, __pyx_L1_error); __Pyx_INCREF(__pyx_v_sec); __Pyx_GIVEREF(__pyx_v_sec); if (__Pyx_PyList_SET_ITEM(__pyx_t_6, 2, __pyx_v_sec)) __PYX_ERR(0, 6270, __pyx_L1_error); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF((PyObject *)(&PyFloat_Type)); __Pyx_GIVEREF((PyObject *)(&PyFloat_Type)); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)(&PyFloat_Type)))) __PYX_ERR(0, 6270, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_6)) __PYX_ERR(0, 6270, __pyx_L1_error); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PySequence_Tuple(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } else {
+6271: else ':'.join([deg, mm, sec])
__Pyx_TraceLine(6271,0,__PYX_ERR(0, 6271, __pyx_L1_error)) __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_deg); __Pyx_GIVEREF(__pyx_v_deg); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_deg)) __PYX_ERR(0, 6271, __pyx_L1_error); __Pyx_INCREF(__pyx_v_mm); __Pyx_GIVEREF(__pyx_v_mm); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 1, __pyx_v_mm)) __PYX_ERR(0, 6271, __pyx_L1_error); __Pyx_INCREF(__pyx_v_sec); __Pyx_GIVEREF(__pyx_v_sec); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 2, __pyx_v_sec)) __PYX_ERR(0, 6271, __pyx_L1_error); __pyx_t_6 = PyUnicode_Join(__pyx_kp_u__32, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
6272:
6273:
+6274: def store_or_write_hdf5 (
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_198store_or_write_hdf5(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_197store_or_write_hdf5, " Store data to hdf5 or write data to csv file. \n \n Note that by default, the data is not store nor write and \n return data if frame or transform the Path-Like object to data frame. \n\n Parameters \n -----------\n d: Dataframe, shape (m_samples, n_features)\n data to store or write or sanitize.\n key:str\n Identifier for the group in the store.\n \n mode: {'a', 'w', 'r+'}, default 'a'\n Mode to open file:\n \n - 'w': write, a new file is created (an existing file with the \n same name would be deleted).\n - 'a': append, an existing file is opened for reading and writing, \n and if the file does not exist it is created.\n - 'r+': similar to 'a', but the file must already exist.\n \n kind: str, {'store', 'write', None} , default=None \n Type of task to perform: \n \n - 'store': Store data to hdf5\n - 'write': export data to csv file.\n - None: construct a dataframe if array is passed or sanitize it. \n\n path_or_buf: str or pandas.HDFStore, or str, path object, file-like object, or None, default=None \n File path or HDFStore object. String, path object\n (implementing os.PathLike[str]), or file-like object implementing \n a write() function. If ``write=True`` and None, the result is returned \n as a string. If a non-binary file object is passed, it should be \n opened with newline=\" \", disabling universal newlines. If a binary \n file object is passed, mode might need to contain a 'b'.\n \n encoding: str, default='utf8'\n A string representing the encoding to use in the output file, \n Encoding is not supported if path_or_buf is a non-binary file object. \n\n csv_sep: str, default=',', \n String of length 1. Field delimiter for the output file.\n \n index: bool, index =False, \n Write data to csv with index or not"". \n \n columns: list of str, optional \n Usefull to create a dataframe when array is passed. Be aware to fit \n the number of array columns (shape[1])\n \n sanitize_columns: bool, default=False, \n remove undesirable character in the data columns using the default\n argument of `regex` parameters and fill pattern to underscore '_'. \n The default regex implementation is:: \n \n >>> import re \n >>> re.compile (r'[_#&.)(*@!,;\\s-]\\s*', flags=re.IGNORECASE)\n \n func: callable, Optional \n A custom sanitizing function and apply to each columns of the dataframe.\n If provide, the expected columns must be listed to `applyto` parameter.\n \n args: tuple, optional \n Positional arguments of the sanitizing columns \n \n applyto: str or list of str, Optional \n The list of columns to apply the function ``func``. To apply the \n function to all columns, use the ``*`` instead. \n \n func_kwds: dict, \n Keywords arguments of the sanitizing function ``func``. \n \n Return \n -------\n None or d: None of dataframe. \n returns None if `kind` is set to ``write`` or ``store`` otherwise \n return the dataframe. \n \n Examples\n --------\n >>> from gofast.tools.coreutils import store_or_write_hdf5\n >>> from gofast.datasets import load_bagoue \n >>> data = load_bagoue().frame \n >>> data.geol[:5]\n 0 VOLCANO-SEDIM. SCHISTS\n 1 GRANITES\n 2 GRANITES\n 3 GRANITES\n 4 GEOSYN. GRANITES\n Name: geol, dtype: object\n >>> data = store_or_write_hdf5 ( data, sanitize_columns = True)\n >>> data[['type', 'geol', 'shape']] # put all to lowercase\n type geol shape\n 0 cp volcano-sedim. schists w\n 1 ec granites v\n 2 ec granites v""\n >>> # compute using func \n >>> def test_func ( a, times , to_percent=False ): \n return ( a * times / 100) if to_percent else ( a *times )\n >>> data.sfi[:5]\n 0 0.388909\n 1 1.340127\n 2 0.446594\n 3 0.763676\n 4 0.068501\n Name: sfi, dtype: float64\n >>> d = store_or_write_hdf5 ( data, func = test_func, args =(7,), applyto='sfi')\n >>> d.sfi[:5] \n 0 2.722360\n 1 9.380889\n 2 3.126156\n 3 5.345733\n 4 0.479507\n Name: sfi, dtype: float64\n >>> store_or_write_hdf5 ( data, func = test_func, args =(7,),\n applyto='sfi', to_percent=True).sfi[:5]\n 0 0.027224\n 1 0.093809\n 2 0.031262\n 3 0.053457\n 4 0.004795\n Name: sfi, dtype: float64\n >>> # write data to hdf5 and outputs to current directory \n >>> store_or_write_hdf5 ( d, key='test0', path_or_buf= 'test_data.h5', \n kind ='store')\n >>> # export data to csv \n >>> store_or_write_hdf5 ( d, key='test0', path_or_buf= 'test_data', \n kind ='export')\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_198store_or_write_hdf5 = {"store_or_write_hdf5", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_198store_or_write_hdf5, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_197store_or_write_hdf5}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_198store_or_write_hdf5(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_key = 0; PyObject *__pyx_v_mode = 0; PyObject *__pyx_v_kind = 0; PyObject *__pyx_v_path_or_buf = 0; PyObject *__pyx_v_encoding = 0; PyObject *__pyx_v_csv_sep = 0; PyObject *__pyx_v_index = 0; PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_sanitize_columns = 0; PyObject *__pyx_v_func = 0; PyObject *__pyx_v_args = 0; PyObject *__pyx_v_applyto = 0; PyObject *__pyx_v_func_kwds = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("store_or_write_hdf5 (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_func_kwds = PyDict_New(); if (unlikely(!__pyx_v_func_kwds)) return NULL; __Pyx_GOTREF(__pyx_v_func_kwds); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_key,&__pyx_n_s_mode,&__pyx_n_s_kind,&__pyx_n_s_path_or_buf,&__pyx_n_s_encoding,&__pyx_n_s_csv_sep,&__pyx_n_s_index,&__pyx_n_s_columns,&__pyx_n_s_sanitize_columns,&__pyx_n_s_func,&__pyx_n_s_args,&__pyx_n_s_applyto,0}; PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_func_kwds); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_197store_or_write_hdf5(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_key, PyObject *__pyx_v_mode, PyObject *__pyx_v_kind, PyObject *__pyx_v_path_or_buf, PyObject *__pyx_v_encoding, PyObject *__pyx_v_csv_sep, PyObject *__pyx_v_index, PyObject *__pyx_v_columns, PyObject *__pyx_v_sanitize_columns, PyObject *__pyx_v_func, PyObject *__pyx_v_args, PyObject *__pyx_v_applyto, PyObject *__pyx_v_func_kwds) { CYTHON_UNUSED PyObject *__pyx_v__ = NULL; PyObject *__pyx_v_cf = NULL; PyObject *__pyx_v_cat = NULL; PyObject *__pyx_v_col = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__243) __Pyx_TraceCall("store_or_write_hdf5", __pyx_f[0], 6274, 0, __PYX_ERR(0, 6274, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_d); __Pyx_INCREF(__pyx_v_kind); __Pyx_INCREF(__pyx_v_path_or_buf); __Pyx_INCREF(__pyx_v_sanitize_columns); __Pyx_INCREF(__pyx_v_applyto); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.store_or_write_hdf5", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_cf); __Pyx_XDECREF(__pyx_v_cat); __Pyx_XDECREF(__pyx_v_col); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_kind); __Pyx_XDECREF(__pyx_v_path_or_buf); __Pyx_XDECREF(__pyx_v_sanitize_columns); __Pyx_XDECREF(__pyx_v_applyto); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__496 = PyTuple_Pack(18, __pyx_n_s_d_3, __pyx_n_s_key, __pyx_n_s_mode, __pyx_n_s_kind, __pyx_n_s_path_or_buf, __pyx_n_s_encoding, __pyx_n_s_csv_sep, __pyx_n_s_index, __pyx_n_s_columns, __pyx_n_s_sanitize_columns, __pyx_n_s_func, __pyx_n_s_args, __pyx_n_s_applyto, __pyx_n_s_func_kwds, __pyx_n_s__8, __pyx_n_s_cf, __pyx_n_s_cat, __pyx_n_s_col); if (unlikely(!__pyx_tuple__496)) __PYX_ERR(0, 6274, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__496); __Pyx_GIVEREF(__pyx_tuple__496); __pyx_codeobj__243 = (PyObject*)__Pyx_PyCode_New(13, 0, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__496, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_store_or_write_hdf5, 6274, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__243)) __PYX_ERR(0, 6274, __pyx_L1_error) /* … */ __Pyx_TraceLine(6274,0,__PYX_ERR(0, 6274, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_key, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_mode, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_kind, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_path_or_buf, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_encoding, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_csv_sep, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_index, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_columns, __pyx_kp_s_Union_str_List_Any) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_sanitize_columns, __pyx_n_s_bool) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_func, __pyx_n_s_F) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_args, __pyx_n_s_tuple) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_applyto, __pyx_kp_s_Union_str_List_Any) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Union_None_DataFrame) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_198store_or_write_hdf5, 0, __pyx_n_s_store_or_write_hdf5, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__243)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6274, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__497); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_store_or_write_hdf5, __pyx_t_5) < 0) __PYX_ERR(0, 6274, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__497 = PyTuple_Pack(12, Py_None, ((PyObject*)__pyx_n_u_a), Py_None, Py_None, ((PyObject*)__pyx_n_u_utf8), ((PyObject*)__pyx_kp_u__48), ((PyObject *)Py_Ellipsis), Py_None, ((PyObject *)Py_Ellipsis), Py_None, ((PyObject*)__pyx_empty_tuple), Py_None); if (unlikely(!__pyx_tuple__497)) __PYX_ERR(0, 6274, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__497); __Pyx_GIVEREF(__pyx_tuple__497);
6275: d,
+6276: key:str= None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_a)));
6277: mode:str='a',
+6278: kind: str=None,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None));
+6279: path_or_buf:str= None,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_utf8))); values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_kp_u__48)));
6280: encoding:str="utf8",
6281: csv_sep: str=",",
+6282: index: bool=...,
values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis)));
+6283: columns:Union [str, List[Any]]=None,
values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+6284: sanitize_columns:bool=...,
values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_Ellipsis)));
+6285: func: _F= None,
values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+6286: args: tuple=(),
values[11] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_empty_tuple)));
+6287: applyto: Union [str, List[Any]]=None,
values[12] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_key); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_mode); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_kind); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_path_or_buf); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_encoding); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_csv_sep); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_index); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_sanitize_columns); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 11: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_args); if (value) { values[11] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 12: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_applyto); if (value) { values[12] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6274, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_func_kwds, values + 0, kwd_pos_args, "store_or_write_hdf5") < 0)) __PYX_ERR(0, 6274, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 13: values[12] = __Pyx_Arg_FASTCALL(__pyx_args, 12); CYTHON_FALLTHROUGH; case 12: values[11] = __Pyx_Arg_FASTCALL(__pyx_args, 11); CYTHON_FALLTHROUGH; case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_d = values[0]; __pyx_v_key = ((PyObject*)values[1]); __pyx_v_mode = ((PyObject*)values[2]); __pyx_v_kind = ((PyObject*)values[3]); __pyx_v_path_or_buf = ((PyObject*)values[4]); __pyx_v_encoding = ((PyObject*)values[5]); __pyx_v_csv_sep = ((PyObject*)values[6]); __pyx_v_index = values[7]; __pyx_v_columns = values[8]; __pyx_v_sanitize_columns = values[9]; __pyx_v_func = values[10]; __pyx_v_args = ((PyObject*)values[11]); __pyx_v_applyto = values[12]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("store_or_write_hdf5", 0, 1, 13, __pyx_nargs); __PYX_ERR(0, 6274, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_func_kwds); __pyx_v_func_kwds = 0; __Pyx_AddTraceback("gofast.tools.coreutils.store_or_write_hdf5", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_key), (&PyUnicode_Type), 1, "key", 1))) __PYX_ERR(0, 6276, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_mode), (&PyUnicode_Type), 0, "mode", 1))) __PYX_ERR(0, 6277, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_kind), (&PyUnicode_Type), 1, "kind", 1))) __PYX_ERR(0, 6278, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_path_or_buf), (&PyUnicode_Type), 1, "path_or_buf", 1))) __PYX_ERR(0, 6279, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_encoding), (&PyUnicode_Type), 0, "encoding", 1))) __PYX_ERR(0, 6280, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_csv_sep), (&PyUnicode_Type), 0, "csv_sep", 1))) __PYX_ERR(0, 6281, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_args), (&PyTuple_Type), 0, "args", 1))) __PYX_ERR(0, 6286, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_197store_or_write_hdf5(__pyx_self, __pyx_v_d, __pyx_v_key, __pyx_v_mode, __pyx_v_kind, __pyx_v_path_or_buf, __pyx_v_encoding, __pyx_v_csv_sep, __pyx_v_index, __pyx_v_columns, __pyx_v_sanitize_columns, __pyx_v_func, __pyx_v_args, __pyx_v_applyto, __pyx_v_func_kwds);
6288: **func_kwds,
6289: )->Union [None, DataFrame]:
6290: """ Store data to hdf5 or write data to csv file.
6291:
6292: Note that by default, the data is not store nor write and
6293: return data if frame or transform the Path-Like object to data frame.
6294:
6295: Parameters
6296: -----------
6297: d: Dataframe, shape (m_samples, n_features)
6298: data to store or write or sanitize.
6299: key:str
6300: Identifier for the group in the store.
6301:
6302: mode: {'a', 'w', 'r+'}, default 'a'
6303: Mode to open file:
6304:
6305: - 'w': write, a new file is created (an existing file with the
6306: same name would be deleted).
6307: - 'a': append, an existing file is opened for reading and writing,
6308: and if the file does not exist it is created.
6309: - 'r+': similar to 'a', but the file must already exist.
6310:
6311: kind: str, {'store', 'write', None} , default=None
6312: Type of task to perform:
6313:
6314: - 'store': Store data to hdf5
6315: - 'write': export data to csv file.
6316: - None: construct a dataframe if array is passed or sanitize it.
6317:
6318: path_or_buf: str or pandas.HDFStore, or str, path object, file-like \
6319: object, or None, default=None
6320: File path or HDFStore object. String, path object
6321: (implementing os.PathLike[str]), or file-like object implementing
6322: a write() function. If ``write=True`` and None, the result is returned
6323: as a string. If a non-binary file object is passed, it should be
6324: opened with newline=" ", disabling universal newlines. If a binary
6325: file object is passed, mode might need to contain a 'b'.
6326:
6327: encoding: str, default='utf8'
6328: A string representing the encoding to use in the output file,
6329: Encoding is not supported if path_or_buf is a non-binary file object.
6330:
6331: csv_sep: str, default=',',
6332: String of length 1. Field delimiter for the output file.
6333:
6334: index: bool, index =False,
6335: Write data to csv with index or not.
6336:
6337: columns: list of str, optional
6338: Usefull to create a dataframe when array is passed. Be aware to fit
6339: the number of array columns (shape[1])
6340:
6341: sanitize_columns: bool, default=False,
6342: remove undesirable character in the data columns using the default
6343: argument of `regex` parameters and fill pattern to underscore '_'.
6344: The default regex implementation is::
6345:
6346: >>> import re
6347: >>> re.compile (r'[_#&.)(*@!,;\s-]\s*', flags=re.IGNORECASE)
6348:
6349: func: callable, Optional
6350: A custom sanitizing function and apply to each columns of the dataframe.
6351: If provide, the expected columns must be listed to `applyto` parameter.
6352:
6353: args: tuple, optional
6354: Positional arguments of the sanitizing columns
6355:
6356: applyto: str or list of str, Optional
6357: The list of columns to apply the function ``func``. To apply the
6358: function to all columns, use the ``*`` instead.
6359:
6360: func_kwds: dict,
6361: Keywords arguments of the sanitizing function ``func``.
6362:
6363: Return
6364: -------
6365: None or d: None of dataframe.
6366: returns None if `kind` is set to ``write`` or ``store`` otherwise
6367: return the dataframe.
6368:
6369: Examples
6370: --------
6371: >>> from gofast.tools.coreutils import store_or_write_hdf5
6372: >>> from gofast.datasets import load_bagoue
6373: >>> data = load_bagoue().frame
6374: >>> data.geol[:5]
6375: 0 VOLCANO-SEDIM. SCHISTS
6376: 1 GRANITES
6377: 2 GRANITES
6378: 3 GRANITES
6379: 4 GEOSYN. GRANITES
6380: Name: geol, dtype: object
6381: >>> data = store_or_write_hdf5 ( data, sanitize_columns = True)
6382: >>> data[['type', 'geol', 'shape']] # put all to lowercase
6383: type geol shape
6384: 0 cp volcano-sedim. schists w
6385: 1 ec granites v
6386: 2 ec granites v
6387: >>> # compute using func
6388: >>> def test_func ( a, times , to_percent=False ):
6389: return ( a * times / 100) if to_percent else ( a *times )
6390: >>> data.sfi[:5]
6391: 0 0.388909
6392: 1 1.340127
6393: 2 0.446594
6394: 3 0.763676
6395: 4 0.068501
6396: Name: sfi, dtype: float64
6397: >>> d = store_or_write_hdf5 ( data, func = test_func, args =(7,), applyto='sfi')
6398: >>> d.sfi[:5]
6399: 0 2.722360
6400: 1 9.380889
6401: 2 3.126156
6402: 3 5.345733
6403: 4 0.479507
6404: Name: sfi, dtype: float64
6405: >>> store_or_write_hdf5 ( data, func = test_func, args =(7,),
6406: applyto='sfi', to_percent=True).sfi[:5]
6407: 0 0.027224
6408: 1 0.093809
6409: 2 0.031262
6410: 3 0.053457
6411: 4 0.004795
6412: Name: sfi, dtype: float64
6413: >>> # write data to hdf5 and outputs to current directory
6414: >>> store_or_write_hdf5 ( d, key='test0', path_or_buf= 'test_data.h5',
6415: kind ='store')
6416: >>> # export data to csv
6417: >>> store_or_write_hdf5 ( d, key='test0', path_or_buf= 'test_data',
6418: kind ='export')
6419: """
+6420: kind= key_search (str(kind), default_keys=(
__Pyx_TraceLine(6420,0,__PYX_ERR(0, 6420, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_key_search); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_kind); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 6420, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); /* … */ __Pyx_TraceLine(6420,0,__PYX_ERR(0, 6420, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6421: "none", "store", "write", "export", "tocsv"),
__Pyx_TraceLine(6421,0,__PYX_ERR(0, 6421, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_default_keys, __pyx_tuple__244) < 0) __PYX_ERR(0, 6420, __pyx_L1_error) /* … */ __pyx_tuple__244 = PyTuple_Pack(5, __pyx_n_u_none, __pyx_n_u_store, __pyx_n_u_write, __pyx_n_u_export, __pyx_n_u_tocsv); if (unlikely(!__pyx_tuple__244)) __PYX_ERR(0, 6421, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__244); __Pyx_GIVEREF(__pyx_tuple__244);
+6422: raise_exception=True , deep=True)[0]
__Pyx_TraceLine(6422,0,__PYX_ERR(0, 6422, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_raise_exception, Py_True) < 0) __PYX_ERR(0, 6420, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_deep, Py_True) < 0) __PYX_ERR(0, 6420, __pyx_L1_error) /* … */ __Pyx_TraceLine(6422,0,__PYX_ERR(0, 6422, __pyx_L1_error)) __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6422, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_2))) __PYX_ERR(0, 6422, __pyx_L1_error) __Pyx_DECREF_SET(__pyx_v_kind, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
6423:
+6424: kind = "export" if kind in ('write', 'tocsv') else kind
__Pyx_TraceLine(6424,0,__PYX_ERR(0, 6424, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_kind); __pyx_t_5 = __pyx_v_kind; __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_n_u_write, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6424, __pyx_L1_error) if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L3_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_n_u_tocsv, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6424, __pyx_L1_error) __pyx_t_6 = __pyx_t_7; __pyx_L3_bool_binop_done:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __pyx_t_6; if (__pyx_t_7) { __Pyx_INCREF(__pyx_n_u_export); __pyx_t_2 = __pyx_n_u_export; } else { __Pyx_INCREF(__pyx_v_kind); __pyx_t_2 = __pyx_v_kind; } __Pyx_DECREF_SET(__pyx_v_kind, ((PyObject*)__pyx_t_2)); __pyx_t_2 = 0;
6425:
+6426: if sanitize_columns is ...:
__Pyx_TraceLine(6426,0,__PYX_ERR(0, 6426, __pyx_L1_error)) __pyx_t_7 = (__pyx_v_sanitize_columns == Py_Ellipsis); if (__pyx_t_7) { /* … */ }
+6427: sanitize_columns=False
__Pyx_TraceLine(6427,0,__PYX_ERR(0, 6427, __pyx_L1_error)) __Pyx_INCREF(Py_False); __Pyx_DECREF_SET(__pyx_v_sanitize_columns, Py_False);
+6428: d = to_numeric_dtypes(d, columns=columns,sanitize_columns=sanitize_columns,
__Pyx_TraceLine(6428,0,__PYX_ERR(0, 6428, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_to_numeric_dtypes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_d)) __PYX_ERR(0, 6428, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_columns, __pyx_v_columns) < 0) __PYX_ERR(0, 6428, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_sanitize_columns, __pyx_v_sanitize_columns) < 0) __PYX_ERR(0, 6428, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_fill_pattern, __pyx_n_u__8) < 0) __PYX_ERR(0, 6428, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6428, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_1); __pyx_t_1 = 0;
6429: fill_pattern='_')
6430:
6431: # get categorical variables
+6432: if ( sanitize_columns
__Pyx_TraceLine(6432,0,__PYX_ERR(0, 6432, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_sanitize_columns); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6432, __pyx_L1_error) if (!__pyx_t_6) { } else { __pyx_t_7 = __pyx_t_6; goto __pyx_L7_bool_binop_done; } /* … */ __Pyx_TraceLine(6432,0,__PYX_ERR(0, 6432, __pyx_L1_error)) if (__pyx_t_7) { /* … */ }
+6433: or func is not None
__Pyx_TraceLine(6433,0,__PYX_ERR(0, 6433, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_func != Py_None); __pyx_t_7 = __pyx_t_6; __pyx_L7_bool_binop_done:;
6434: ):
+6435: d, _, cf = to_numeric_dtypes(d, return_feature_types= True )
__Pyx_TraceLine(6435,0,__PYX_ERR(0, 6435, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_to_numeric_dtypes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_d)) __PYX_ERR(0, 6435, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_return_feature_types, Py_True) < 0) __PYX_ERR(0, 6435, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 6435, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); __pyx_t_1 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6435, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); index = 0; __pyx_t_4 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_4)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_3 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 2; __pyx_t_1 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(0, 6435, __pyx_L1_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L10_unpacking_done; __pyx_L9_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 6435, __pyx_L1_error) __pyx_L10_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_4); __pyx_t_4 = 0; __pyx_v__ = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_cf = __pyx_t_1; __pyx_t_1 = 0;
6436: #( strip then pass to lower case all non-numerical data)
6437: # for minimum sanitization
+6438: for cat in cf :
__Pyx_TraceLine(6438,0,__PYX_ERR(0, 6438, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_cf)) || PyTuple_CheckExact(__pyx_v_cf)) { __pyx_t_2 = __pyx_v_cf; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_cf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6438, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6438, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6438, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6438, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6438, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6438, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6438, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_v_cat, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(6438,0,__PYX_ERR(0, 6438, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6439: d[cat]= d[cat].str.lower()
__Pyx_TraceLine(6439,0,__PYX_ERR(0, 6439, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_v_cat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_str_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_12, 0+__pyx_t_12); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6439, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_d, __pyx_v_cat, __pyx_t_1) < 0))) __PYX_ERR(0, 6439, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+6440: d[cat]= d[cat].str.strip()
__Pyx_TraceLine(6440,0,__PYX_ERR(0, 6440, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_v_cat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_str_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strip); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_12, 0+__pyx_t_12); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_d, __pyx_v_cat, __pyx_t_1) < 0))) __PYX_ERR(0, 6440, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6441:
+6442: if func is not None:
__Pyx_TraceLine(6442,0,__PYX_ERR(0, 6442, __pyx_L1_error)) __pyx_t_7 = (__pyx_v_func != Py_None); if (__pyx_t_7) { /* … */ }
+6443: if not callable(func):
__Pyx_TraceLine(6443,0,__PYX_ERR(0, 6443, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyCallable_Check(__pyx_v_func); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 6443, __pyx_L1_error) __pyx_t_6 = (!__pyx_t_7); if (unlikely(__pyx_t_6)) { /* … */ }
+6444: raise TypeError(
__Pyx_TraceLine(6444,0,__PYX_ERR(0, 6444, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6444, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 6444, __pyx_L1_error)
+6445: f"Expect a callable for `func`. Got {type(func).__name__!r}")
__Pyx_TraceLine(6445,0,__PYX_ERR(0, 6445, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_func)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_a_callable_for_func_Got, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6445, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6446:
+6447: if applyto is None:
__Pyx_TraceLine(6447,0,__PYX_ERR(0, 6447, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_applyto == Py_None); if (unlikely(__pyx_t_6)) { /* … */ }
+6448: raise ValueError("Need to specify the data column to apply"
__Pyx_TraceLine(6448,0,__PYX_ERR(0, 6448, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = 0; __pyx_t_13 = 127; __Pyx_INCREF(__pyx_kp_u_Need_to_specify_the_data_column); __pyx_t_10 += 40; __Pyx_GIVEREF(__pyx_kp_u_Need_to_specify_the_data_column); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Need_to_specify_the_data_column); /* … */ __Pyx_TraceLine(6448,0,__PYX_ERR(0, 6448, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_10, __pyx_t_13); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6448, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 6448, __pyx_L1_error)
+6449: f"{func.__name__!r} to.")
__Pyx_TraceLine(6449,0,__PYX_ERR(0, 6449, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_func, __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_13 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_13) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_13; __pyx_t_10 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_to_2); __pyx_t_10 += 4; __Pyx_GIVEREF(__pyx_kp_u_to_2); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_to_2);
6450:
+6451: applyto = is_iterable( applyto, exclude_string=True,
__Pyx_TraceLine(6451,0,__PYX_ERR(0, 6451, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_applyto); __Pyx_GIVEREF(__pyx_v_applyto); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_applyto)) __PYX_ERR(0, 6451, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 6451, __pyx_L1_error) /* … */ __Pyx_TraceLine(6451,0,__PYX_ERR(0, 6451, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6451, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_8; __pyx_t_8 = 0; } else {
+6452: transform =True ) if applyto !="*" else d.columns
__Pyx_TraceLine(6452,0,__PYX_ERR(0, 6452, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_applyto, __pyx_kp_u__36, Py_NE)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6452, __pyx_L1_error) if (__pyx_t_6) { /* … */ __Pyx_TraceLine(6452,0,__PYX_ERR(0, 6452, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 6451, __pyx_L1_error) /* … */ __Pyx_TraceLine(6452,0,__PYX_ERR(0, 6452, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_columns); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_1 = __pyx_t_8; __pyx_t_8 = 0; } __Pyx_DECREF_SET(__pyx_v_applyto, __pyx_t_1); __pyx_t_1 = 0;
6453: # check whether the applyto columns are in data columns
+6454: exist_features(d, applyto)
__Pyx_TraceLine(6454,0,__PYX_ERR(0, 6454, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_exist_features); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_8))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_d, __pyx_v_applyto}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_12, 2+__pyx_t_12); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6455:
6456: # map each colum
+6457: for col in applyto:
__Pyx_TraceLine(6457,0,__PYX_ERR(0, 6457, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_applyto)) || PyTuple_CheckExact(__pyx_v_applyto)) { __pyx_t_1 = __pyx_v_applyto; __Pyx_INCREF(__pyx_t_1); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_applyto); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6457, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6457, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6457, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6457, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10); __Pyx_INCREF(__pyx_t_8); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 6457, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6457, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_v_col, __pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(6457,0,__PYX_ERR(0, 6457, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+6458: d [col]=d[col].apply( func, args=args, **func_kwds )
__Pyx_TraceLine(6458,0,__PYX_ERR(0, 6458, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_v_col); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_apply); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_func); __Pyx_GIVEREF(__pyx_v_func); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_func)) __PYX_ERR(0, 6458, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_args, __pyx_v_args) < 0) __PYX_ERR(0, 6458, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; if (__Pyx_MergeKeywords(__pyx_t_2, __pyx_v_func_kwds) < 0) __PYX_ERR(0, 6458, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6458, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely((PyObject_SetItem(__pyx_v_d, __pyx_v_col, __pyx_t_3) < 0))) __PYX_ERR(0, 6458, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6459:
6460: # store in h5 file.
+6461: if kind=='store':
__Pyx_TraceLine(6461,0,__PYX_ERR(0, 6461, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_kind, __pyx_n_u_store, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6461, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+6462: if path_or_buf is None:
__Pyx_TraceLine(6462,0,__PYX_ERR(0, 6462, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_path_or_buf == ((PyObject*)Py_None)); if (__pyx_t_6) { /* … */ }
+6463: print("Destination file is missing. Use 'data.h5' instead outputs"
__Pyx_TraceLine(6463,0,__PYX_ERR(0, 6463, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Destination_file_is_missing_Use, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6463, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6464: f" in the current directory {os.getcwd()}")
__Pyx_TraceLine(6464,0,__PYX_ERR(0, 6464, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_getcwd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_12, 0+__pyx_t_12); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+6465: path_or_buf= 'data.h5'
__Pyx_TraceLine(6465,0,__PYX_ERR(0, 6465, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_data_h5); __Pyx_DECREF_SET(__pyx_v_path_or_buf, __pyx_kp_u_data_h5);
6466:
+6467: d.to_hdf ( path_or_buf , key =key, mode =mode )
__Pyx_TraceLine(6467,0,__PYX_ERR(0, 6467, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_to_hdf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_path_or_buf); __Pyx_GIVEREF(__pyx_v_path_or_buf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_path_or_buf)) __PYX_ERR(0, 6467, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_key, __pyx_v_key) < 0) __PYX_ERR(0, 6467, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_mode, __pyx_v_mode) < 0) __PYX_ERR(0, 6467, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6468: # export to csv file
+6469: if kind=="export":
__Pyx_TraceLine(6469,0,__PYX_ERR(0, 6469, __pyx_L1_error)) __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_kind, __pyx_n_u_export, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6469, __pyx_L1_error) if (__pyx_t_6) { /* … */ }
+6470: d.to_csv(path_or_buf, encoding = encoding , sep=csv_sep ,
__Pyx_TraceLine(6470,0,__PYX_ERR(0, 6470, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_to_csv); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_path_or_buf); __Pyx_GIVEREF(__pyx_v_path_or_buf); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_path_or_buf)) __PYX_ERR(0, 6470, __pyx_L1_error); __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_encoding, __pyx_v_encoding) < 0) __PYX_ERR(0, 6470, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_sep, __pyx_v_csv_sep) < 0) __PYX_ERR(0, 6470, __pyx_L1_error) /* … */ __Pyx_TraceLine(6470,0,__PYX_ERR(0, 6470, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6470, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6471: index =False if index is ... else index )
__Pyx_TraceLine(6471,0,__PYX_ERR(0, 6471, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_index == Py_Ellipsis); if (__pyx_t_6) { __Pyx_INCREF(Py_False); __pyx_t_2 = Py_False; } else { __Pyx_INCREF(__pyx_v_index); __pyx_t_2 = __pyx_v_index; } if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_index, __pyx_t_2) < 0) __PYX_ERR(0, 6470, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6472:
+6473: return d if kind not in ("store", "export") else None
__Pyx_TraceLine(6473,0,__PYX_ERR(0, 6473, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_kind); __pyx_t_5 = __pyx_v_kind; __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_n_u_store, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6473, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L23_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_n_u_export, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6473, __pyx_L1_error) __pyx_t_6 = __pyx_t_7; __pyx_L23_bool_binop_done:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __pyx_t_6; if (__pyx_t_7) { __Pyx_INCREF(__pyx_v_d); __pyx_t_2 = __pyx_v_d; } else { __Pyx_INCREF(Py_None); __pyx_t_2 = Py_None; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
6474:
+6475: def ellipsis2false( *parameters , default_value: Any=False ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_200ellipsis2false(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_199ellipsis2false, " Turn all parameter arguments to False if ellipsis.\n \n Note that the output arguments must be in the same order like the \n positional arguments. \n \n :param parameters: tuple \n List of parameters \n :param default_value: Any, \n Value by default that might be take the ellipsis. \n :return: tuple, same list of parameters passed ellipsis to \n ``default_value``. By default, it returns ``False``. For a single \n parameters, uses the trailing comma for collecting the parameters \n \n :example: \n >>> from gofast.tools.coreutils import ellipsis2false \n >>> var, = ellipsis2false (...)\n >>> var \n False\n >>> data, sep , verbose = ellipsis2false ([2,3, 4], ',', ...)\n >>> verbose \n False \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_200ellipsis2false = {"ellipsis2false", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_200ellipsis2false, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_199ellipsis2false}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_200ellipsis2false(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_default_value = 0; PyObject *__pyx_v_parameters = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ellipsis2false (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_parameters = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_default_value,0}; PyObject* values[1] = {0}; values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args == 1) { const Py_ssize_t index = 0; PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6475, __pyx_L3_error) } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "ellipsis2false") < 0)) __PYX_ERR(0, 6475, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_default_value = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("ellipsis2false", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 6475, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_parameters); __pyx_v_parameters = 0; __Pyx_AddTraceback("gofast.tools.coreutils.ellipsis2false", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_199ellipsis2false(__pyx_self, __pyx_v_default_value, __pyx_v_parameters); /* function exit code */ __Pyx_DECREF(__pyx_v_parameters); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_14ellipsis2false_2generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_199ellipsis2false(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_default_value, PyObject *__pyx_v_parameters) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false *__pyx_cur_scope; PyObject *__pyx_gb_6gofast_5tools_9coreutils_14ellipsis2false_2generator7 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__245) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 6475, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("ellipsis2false", __pyx_f[0], 6475, 0, __PYX_ERR(0, 6475, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_default_value = __pyx_v_default_value; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_default_value); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_default_value); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gofast.tools.coreutils.ellipsis2false", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_14ellipsis2false_2generator7); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__498 = PyTuple_Pack(4, __pyx_n_s_default_value, __pyx_n_s_parameters, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__498)) __PYX_ERR(0, 6475, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__498); __Pyx_GIVEREF(__pyx_tuple__498); /* … */ __Pyx_TraceLine(6475,0,__PYX_ERR(0, 6475, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_default_value, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 6475, __pyx_L1_error) __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_default_value, __pyx_n_s_Any) < 0) __PYX_ERR(0, 6475, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_200ellipsis2false, 0, __pyx_n_s_ellipsis2false, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__245)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_8, __pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_ellipsis2false, __pyx_t_8) < 0) __PYX_ERR(0, 6475, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__245 = (PyObject*)__Pyx_PyCode_New(0, 0, 1, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__498, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_ellipsis2false, 6475, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__245)) __PYX_ERR(0, 6475, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false { PyObject_HEAD PyObject *__pyx_v_default_value; };
6476: """ Turn all parameter arguments to False if ellipsis.
6477:
6478: Note that the output arguments must be in the same order like the
6479: positional arguments.
6480:
6481: :param parameters: tuple
6482: List of parameters
6483: :param default_value: Any,
6484: Value by default that might be take the ellipsis.
6485: :return: tuple, same list of parameters passed ellipsis to
6486: ``default_value``. By default, it returns ``False``. For a single
6487: parameters, uses the trailing comma for collecting the parameters
6488:
6489: :example:
6490: >>> from gofast.tools.coreutils import ellipsis2false
6491: >>> var, = ellipsis2false (...)
6492: >>> var
6493: False
6494: >>> data, sep , verbose = ellipsis2false ([2,3, 4], ',', ...)
6495: >>> verbose
6496: False
6497: """
+6498: return tuple ( ( default_value if param is ... else param
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_14ellipsis2false_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_22_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_22_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_22_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_22_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_22_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 6498, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false *) __pyx_self;
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_14ellipsis2false_2generator7, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_ellipsis2false_locals_genexpr, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 6498, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.ellipsis2false.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_14ellipsis2false_2generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6498, __pyx_L1_error)
/* … */
__Pyx_TraceLine(6498,0,__PYX_ERR(0, 6498, __pyx_L1_error))
__pyx_t_4 = (__pyx_cur_scope->__pyx_v_param == Py_Ellipsis);
if (__pyx_t_4) {
if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_default_value)) { __Pyx_RaiseClosureNameError("default_value"); __PYX_ERR(0, 6498, __pyx_L1_error) }
__Pyx_INCREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_default_value);
__pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_default_value;
} else {
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_param);
__pyx_t_3 = __pyx_cur_scope->__pyx_v_param;
}
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
__Pyx_XGIVEREF(__pyx_t_1);
__pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
__pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
/* return from generator, yielding value */
__pyx_generator->resume_label = 1;
return __pyx_r;
__pyx_L6_resume_from_yield:;
__pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
__pyx_cur_scope->__pyx_t_0 = 0;
__Pyx_XGOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6498, __pyx_L1_error)
/* … */
/* function exit code */
PyErr_SetNone(PyExc_StopIteration);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(6498,0,__PYX_ERR(0, 6498, __pyx_L1_error))
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(6499,0,__PYX_ERR(0, 6499, __pyx_L1_error))
__pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_14ellipsis2false_genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_parameters); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6498, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
/* … */
__Pyx_TraceLine(6498,0,__PYX_ERR(0, 6498, __pyx_L1_error))
__pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6498, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_22_genexpr {
PyObject_HEAD
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_21_ellipsis2false *__pyx_outer_scope;
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_param;
PyObject *__pyx_t_0;
Py_ssize_t __pyx_t_1;
};
+6499: for param in parameters) )
__Pyx_TraceLine(6499,0,__PYX_ERR(0, 6499, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 6499, __pyx_L1_error) } __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6499, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 6499, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6499, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_param); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_param, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(6499,0,__PYX_ERR(0, 6499, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
6500:
+6501: def type_of_target(y):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_202type_of_target(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_201type_of_target, "\n Determine the type of data indicated by the target variable.\n\n Parameters\n ----------\n y : array-like\n Target values. \n\n Returns\n -------\n target_type : string\n Type of target data, such as 'binary', 'multiclass', 'continuous', etc.\n\n Examples\n --------\n >>> type_of_target([0, 1, 1, 0])\n 'binary'\n >>> type_of_target([0.5, 1.5, 2.5])\n 'continuous'\n >>> type_of_target([[1, 0], [0, 1]])\n 'multilabel-indicator'\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_202type_of_target = {"type_of_target", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_202type_of_target, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_201type_of_target}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_202type_of_target(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_y = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("type_of_target (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_y_4,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_y_4)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6501, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "type_of_target") < 0)) __PYX_ERR(0, 6501, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_y = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("type_of_target", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6501, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.type_of_target", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_201type_of_target(__pyx_self, __pyx_v_y); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_2generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_201type_of_target(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_y) { PyObject *__pyx_v_unique_values = NULL; PyObject *__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_2generator8 = 0; PyObject *__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_5generator9 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__246) __Pyx_TraceCall("type_of_target", __pyx_f[0], 6501, 0, __PYX_ERR(0, 6501, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.type_of_target", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_unique_values); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_2generator8); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_5generator9); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__499 = PyTuple_Pack(5, __pyx_n_s_y_4, __pyx_n_s_unique_values, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__499)) __PYX_ERR(0, 6501, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__499); __Pyx_GIVEREF(__pyx_tuple__499); /* … */ __Pyx_TraceLine(6501,0,__PYX_ERR(0, 6501, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_202type_of_target, 0, __pyx_n_s_type_of_target, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__246)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_type_of_target, __pyx_t_8) < 0) __PYX_ERR(0, 6501, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__246 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__499, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_type_of_target, 6501, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__246)) __PYX_ERR(0, 6501, __pyx_L1_error)
6502: """
6503: Determine the type of data indicated by the target variable.
6504:
6505: Parameters
6506: ----------
6507: y : array-like
6508: Target values.
6509:
6510: Returns
6511: -------
6512: target_type : string
6513: Type of target data, such as 'binary', 'multiclass', 'continuous', etc.
6514:
6515: Examples
6516: --------
6517: >>> type_of_target([0, 1, 1, 0])
6518: 'binary'
6519: >>> type_of_target([0.5, 1.5, 2.5])
6520: 'continuous'
6521: >>> type_of_target([[1, 0], [0, 1]])
6522: 'multilabel-indicator'
6523: """
6524: # Check if y is an array-like
+6525: if not isinstance(y, (np.ndarray, list, pd.Series, Sequence, pd.DataFrame)):
__Pyx_TraceLine(6525,0,__PYX_ERR(0, 6525, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6525, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = PyObject_IsInstance(__pyx_v_y, __pyx_t_2); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = PyList_Check(__pyx_v_y); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = PyObject_IsInstance(__pyx_v_y, __pyx_t_3); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = PyObject_IsInstance(__pyx_v_y, __pyx_t_1); if (!__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = PyObject_IsInstance(__pyx_v_y, __pyx_t_5); __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (!__pyx_t_6); if (unlikely(__pyx_t_7)) { /* … */ }
+6526: raise ValueError("Expected array-like (array or list), got %s" % type(y))
__Pyx_TraceLine(6526,0,__PYX_ERR(0, 6526, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_Expected_array_like_array_or_lis, ((PyObject *)Py_TYPE(__pyx_v_y))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 6526, __pyx_L1_error)
6527:
6528: # Check for valid number type
+6529: if not all(isinstance(i, (int, float, np.integer, np.floating))
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_14type_of_target_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_23_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_23_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_23_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_23_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_23_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 6529, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_14type_of_target_2generator8, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_type_of_target_locals_genexpr, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.type_of_target.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_2generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6529, __pyx_L1_error)
/* … */
__Pyx_TraceLine(6529,0,__PYX_ERR(0, 6529, __pyx_L1_error))
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_integer); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_floating); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_8 = PyInt_Check(__pyx_cur_scope->__pyx_v_i);
if (!__pyx_t_8) {
} else {
__pyx_t_7 = __pyx_t_8;
goto __pyx_L7_bool_binop_done;
}
__pyx_t_8 = PyFloat_Check(__pyx_cur_scope->__pyx_v_i);
if (!__pyx_t_8) {
} else {
__pyx_t_7 = __pyx_t_8;
goto __pyx_L7_bool_binop_done;
}
__pyx_t_8 = PyObject_IsInstance(__pyx_cur_scope->__pyx_v_i, __pyx_t_5);
if (!__pyx_t_8) {
} else {
__pyx_t_7 = __pyx_t_8;
goto __pyx_L7_bool_binop_done;
}
__pyx_t_8 = PyObject_IsInstance(__pyx_cur_scope->__pyx_v_i, __pyx_t_6);
__pyx_t_7 = __pyx_t_8;
__pyx_L7_bool_binop_done:;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_8 = (!__pyx_t_7);
if (__pyx_t_8) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
/* … */
__Pyx_TraceLine(6529,0,__PYX_ERR(0, 6529, __pyx_L1_error))
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_5generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
/* … */
__Pyx_TraceLine(6529,0,__PYX_ERR(0, 6529, __pyx_L1_error))
__pyx_t_5 = __pyx_pf_6gofast_5tools_9coreutils_14type_of_target_genexpr(NULL, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_Generator_Next(__pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6529, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_6 = (!__pyx_t_7);
if (unlikely(__pyx_t_6)) {
/* … */
}
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_23_genexpr {
PyObject_HEAD
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_i;
};
+6530: for i in np.array(y).flatten()):
__Pyx_TraceLine(6530,0,__PYX_ERR(0, 6530, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 6530, __pyx_L1_error) } if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) { __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6530, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_3)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6530, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 6530, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6530, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 6530, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6530, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(6530,0,__PYX_ERR(0, 6530, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*else*/ { /* … */ __Pyx_TraceLine(6530,0,__PYX_ERR(0, 6530, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_y}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_flatten); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; }
+6531: raise ValueError("Input must be a numeric array-like")
__Pyx_TraceLine(6531,0,__PYX_ERR(0, 6531, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__247, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6531, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 6531, __pyx_L1_error) /* … */ __pyx_tuple__247 = PyTuple_Pack(1, __pyx_kp_u_Input_must_be_a_numeric_array_li); if (unlikely(!__pyx_tuple__247)) __PYX_ERR(0, 6531, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__247); __Pyx_GIVEREF(__pyx_tuple__247);
6532:
6533: # Continuous data
+6534: if any(isinstance(i, float) for i in np.array(y).flatten()):
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_14type_of_target_3genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_24_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_24_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_24_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_24_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_24_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 6534, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_14type_of_target_5generator9, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_type_of_target_locals_genexpr, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.type_of_target.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_14type_of_target_5generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6534, __pyx_L1_error)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 6534, __pyx_L1_error) }
if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
__pyx_t_3 = NULL;
} else {
__pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6534, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_3)) {
if (likely(PyList_CheckExact(__pyx_t_1))) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6534, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 6534, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
} else {
{
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6534, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 6534, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
}
} else {
__pyx_t_4 = __pyx_t_3(__pyx_t_1);
if (unlikely(!__pyx_t_4)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(0, 6534, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_4);
}
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
__pyx_t_5 = PyFloat_Check(__pyx_cur_scope->__pyx_v_i);
if (__pyx_t_5) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(6534,0,__PYX_ERR(0, 6534, __pyx_L1_error))
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
__pyx_t_8 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_1))) {
__pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
if (likely(__pyx_t_2)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
__Pyx_INCREF(__pyx_t_2);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_1, function);
__pyx_t_8 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_y};
__pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_flatten); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = NULL;
__pyx_t_8 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_1))) {
__pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
if (likely(__pyx_t_5)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
__Pyx_INCREF(__pyx_t_5);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_1, function);
__pyx_t_8 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
__pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
__pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_14type_of_target_3genexpr(NULL, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6534, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (__pyx_t_6) {
/* … */
}
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_24_genexpr {
PyObject_HEAD
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_i;
};
+6535: return 'continuous'
__Pyx_TraceLine(6535,0,__PYX_ERR(0, 6535, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_u_continuous); __pyx_r = __pyx_n_u_continuous; goto __pyx_L0;
6536:
6537: # Binary or multiclass
+6538: unique_values = np.unique(y)
__Pyx_TraceLine(6538,0,__PYX_ERR(0, 6538, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_unique); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_y}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6538, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_v_unique_values = __pyx_t_3; __pyx_t_3 = 0;
+6539: if len(unique_values) == 2:
__Pyx_TraceLine(6539,0,__PYX_ERR(0, 6539, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_unique_values); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6539, __pyx_L1_error) __pyx_t_6 = (__pyx_t_9 == 2); if (__pyx_t_6) { /* … */ }
+6540: return 'binary'
__Pyx_TraceLine(6540,0,__PYX_ERR(0, 6540, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_u_binary); __pyx_r = __pyx_n_u_binary; goto __pyx_L0;
+6541: elif len(unique_values) > 2 and np.ndim(y) == 1:
__Pyx_TraceLine(6541,0,__PYX_ERR(0, 6541, __pyx_L1_error)) __pyx_t_9 = PyObject_Length(__pyx_v_unique_values); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6541, __pyx_L1_error) __pyx_t_7 = (__pyx_t_9 > 2); if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L12_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_y}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_7 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_3, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6541, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __pyx_t_7; __pyx_L12_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+6542: return 'multiclass'
__Pyx_TraceLine(6542,0,__PYX_ERR(0, 6542, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_u_multiclass); __pyx_r = __pyx_n_u_multiclass; goto __pyx_L0;
6543:
6544: # Multilabel indicator
+6545: if isinstance(y[0], (np.ndarray, list, Sequence)) and len(y[0]) > 1:
__Pyx_TraceLine(6545,0,__PYX_ERR(0, 6545, __pyx_L1_error)) __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_y, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Sequence); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = PyObject_IsInstance(__pyx_t_3, __pyx_t_5); if (!__pyx_t_10) { } else { __pyx_t_7 = __pyx_t_10; goto __pyx_L17_bool_binop_done; } __pyx_t_10 = PyList_Check(__pyx_t_3); if (!__pyx_t_10) { } else { __pyx_t_7 = __pyx_t_10; goto __pyx_L17_bool_binop_done; } __pyx_t_10 = PyObject_IsInstance(__pyx_t_3, __pyx_t_1); __pyx_t_7 = __pyx_t_10; __pyx_L17_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L15_bool_binop_done; } __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_y, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6545, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (__pyx_t_9 > 1); __pyx_t_6 = __pyx_t_7; __pyx_L15_bool_binop_done:; if (__pyx_t_6) { /* … */ }
+6546: return 'multilabel-indicator'
__Pyx_TraceLine(6546,0,__PYX_ERR(0, 6546, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_kp_u_multilabel_indicator); __pyx_r = __pyx_kp_u_multilabel_indicator; goto __pyx_L0;
6547:
+6548: return 'unknown'
__Pyx_TraceLine(6548,0,__PYX_ERR(0, 6548, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_u_unknown); __pyx_r = __pyx_n_u_unknown; goto __pyx_L0;
6549:
6550:
+6551: def add_noises_to(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_334__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 6551, 0, __PYX_ERR(0, 6551, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(6555,0,__PYX_ERR(0, 6555, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6551, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject*)__pyx_float_0_1));
__Pyx_GIVEREF(((PyObject*)__pyx_float_0_1));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject*)__pyx_float_0_1))) __PYX_ERR(0, 6551, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, Py_None)) __PYX_ERR(0, 6551, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_False));
__Pyx_GIVEREF(((PyObject *)Py_False));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)Py_False))) __PYX_ERR(0, 6551, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_self)->__pyx_arg_cat_missing_value);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_self)->__pyx_arg_cat_missing_value);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, __Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_self)->__pyx_arg_cat_missing_value)) __PYX_ERR(0, 6551, __pyx_L1_error);
/* … */
__Pyx_TraceLine(6551,0,__PYX_ERR(0, 6551, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6551, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 6551, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 6551, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_204add_noises_to(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_203add_noises_to, "\n Adds NaN or specified missing values to a pandas DataFrame.\n\n Parameters\n ----------\n data : pandas.DataFrame\n The DataFrame to which NaN values or specified missing \n values will be added.\n\n noise : float, default=0.1\n The percentage of values to be replaced with NaN or the \n specified missing value in each column. This must be a \n number between 0 and 1. Default is 0.1 (10%).\n\n .. math:: \text{noise} = \014rac{\text{number of replaced values}}{\text{total values in column}}\n\n seed : int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional\n Seed for random number generator to ensure reproducibility. \n If `seed` is an int, array-like, or BitGenerator, it will be \n used to seed the random number generator. If `seed` is a \n np.random.RandomState or np.random.Generator, it will be used \n as given.\n\n gaussian_noise : bool, default=False\n If `True`, adds Gaussian noise to the data. Otherwise, replaces \n values with NaN or the specified missing value.\n\n cat_missing_value : scalar, default=pd.NA\n The value to use for missing data in categorical columns. By \n default, `pd.NA` is used.\n\n Returns\n -------\n pandas.DataFrame\n A DataFrame with NaN or specified missing values added.\n\n Notes\n -----\n The function modifies the DataFrame by either adding Gaussian noise \n to numerical columns or replacing a percentage of values in each \n column with NaN or a specified missing value.\n\n The Gaussian noise is added according to the formula:\n\n .. math:: \text{new_value} = \text{original_value} + \\mathcal{N}(0, \text{noise})\n\n where :math:`\\mathcal{N}(0, \text{noise})` represents a normal \n distribution with mean 0 and standard deviation equal to `noise`.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import add_noises_to""\n >>> import pandas as pd\n >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': ['x', 'y', 'z']})\n >>> new_df = add_noises_to(df, noise=0.2)\n >>> new_df\n A B\n 0 1.0 <NA>\n 1 NaN y\n 2 3.0 <NA>\n\n >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\n >>> new_df = add_noises_to(df, noise=0.1, gaussian_noise=True)\n >>> new_df\n A B\n 0 1.063292 3.986400\n 1 2.103962 4.984292\n 2 2.856601 6.017380\n\n See Also\n --------\n pandas.DataFrame : Two-dimensional, size-mutable, potentially \n heterogeneous tabular data.\n numpy.random.normal : Draw random samples from a normal \n (Gaussian) distribution.\n\n References\n ----------\n .. [1] Harris, C. R., Millman, K. J., van der Walt, S. J., et al. \n (2020). Array programming with NumPy. Nature, 585(7825), \n 357-362.\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_204add_noises_to = {"add_noises_to", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_204add_noises_to, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_203add_noises_to};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_204add_noises_to(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_data = 0;
PyObject *__pyx_v_noise = 0;
PyObject *__pyx_v_seed = 0;
PyObject *__pyx_v_gaussian_noise = 0;
PyObject *__pyx_v_cat_missing_value = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("add_noises_to (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_noise,&__pyx_n_s_seed,&__pyx_n_s_gaussian_noise,&__pyx_n_s_cat_missing_value,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults14 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_self);
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_0_1)));
/* … */
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_203add_noises_to(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_noise, PyObject *__pyx_v_seed, PyObject *__pyx_v_gaussian_noise, PyObject *__pyx_v_cat_missing_value) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to *__pyx_cur_scope;
int __pyx_v_is_frame;
PyObject *__pyx_v_add_gaussian_noise = 0;
PyObject *__pyx_v_noise_data = NULL;
PyObject *__pyx_v_df_with_nan = NULL;
PyObject *__pyx_v_nan_count_per_column = NULL;
PyObject *__pyx_v_column = NULL;
PyObject *__pyx_v_nan_indices = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__248)
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 6551, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__Pyx_TraceCall("add_noises_to", __pyx_f[0], 6551, 0, __PYX_ERR(0, 6551, __pyx_L1_error));
__pyx_cur_scope->__pyx_v_noise = __pyx_v_noise;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_noise);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_noise);
__Pyx_INCREF(__pyx_v_data);
__Pyx_INCREF(__pyx_v_gaussian_noise);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_AddTraceback("gofast.tools.coreutils.add_noises_to", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_add_gaussian_noise);
__Pyx_XDECREF(__pyx_v_noise_data);
__Pyx_XDECREF(__pyx_v_df_with_nan);
__Pyx_XDECREF(__pyx_v_nan_count_per_column);
__Pyx_XDECREF(__pyx_v_column);
__Pyx_XDECREF(__pyx_v_nan_indices);
__Pyx_XDECREF(__pyx_v_data);
__Pyx_XDECREF(__pyx_v_gaussian_noise);
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__500 = PyTuple_Pack(13, __pyx_n_s_data, __pyx_n_s_noise, __pyx_n_s_seed, __pyx_n_s_gaussian_noise, __pyx_n_s_cat_missing_value, __pyx_n_s_is_frame, __pyx_n_s_add_gaussian_noise, __pyx_n_s_add_gaussian_noise, __pyx_n_s_noise_data, __pyx_n_s_df_with_nan, __pyx_n_s_nan_count_per_column, __pyx_n_s_column, __pyx_n_s_nan_indices); if (unlikely(!__pyx_tuple__500)) __PYX_ERR(0, 6551, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__500);
__Pyx_GIVEREF(__pyx_tuple__500);
/* … */
__Pyx_TraceLine(6551,0,__PYX_ERR(0, 6551, __pyx_L1_error))
__pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_204add_noises_to, 0, __pyx_n_s_add_noises_to, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__248)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6551, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_8, sizeof(__pyx_defaults14), 1)) __PYX_ERR(0, 6551, __pyx_L1_error)
__pyx_codeobj__248 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__500, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_add_noises_to, 6551, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__248)) __PYX_ERR(0, 6551, __pyx_L1_error)
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to {
PyObject_HEAD
PyObject *__pyx_v_noise;
};
6552: data,
6553: noise=0.1,
+6554: seed=None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_cat_missing_value); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6551, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_noise); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6551, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_seed); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6551, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_gaussian_noise); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6551, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cat_missing_value); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6551, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "add_noises_to") < 0)) __PYX_ERR(0, 6551, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_noise = values[1]; __pyx_v_seed = values[2]; __pyx_v_gaussian_noise = values[3]; __pyx_v_cat_missing_value = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("add_noises_to", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 6551, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.add_noises_to", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_203add_noises_to(__pyx_self, __pyx_v_data, __pyx_v_noise, __pyx_v_seed, __pyx_v_gaussian_noise, __pyx_v_cat_missing_value);
6555: gaussian_noise=False,
+6556: cat_missing_value=pd.NA
__Pyx_TraceLine(6556,0,__PYX_ERR(0, 6556, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_NA); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6556, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults14, __pyx_t_8)->__pyx_arg_cat_missing_value = __pyx_t_5; __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_8, __pyx_pf_6gofast_5tools_9coreutils_334__defaults__); if (PyDict_SetItem(__pyx_d, __pyx_n_s_add_noises_to, __pyx_t_8) < 0) __PYX_ERR(0, 6551, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6557: ):
6558: """
6559: Adds NaN or specified missing values to a pandas DataFrame.
6560:
6561: Parameters
6562: ----------
6563: data : pandas.DataFrame
6564: The DataFrame to which NaN values or specified missing
6565: values will be added.
6566:
6567: noise : float, default=0.1
6568: The percentage of values to be replaced with NaN or the
6569: specified missing value in each column. This must be a
6570: number between 0 and 1. Default is 0.1 (10%).
6571:
6572: .. math:: \text{noise} = \frac{\text{number of replaced values}}{\text{total values in column}}
6573:
6574: seed : int, array-like, BitGenerator, np.random.RandomState, np.random.Generator, optional
6575: Seed for random number generator to ensure reproducibility.
6576: If `seed` is an int, array-like, or BitGenerator, it will be
6577: used to seed the random number generator. If `seed` is a
6578: np.random.RandomState or np.random.Generator, it will be used
6579: as given.
6580:
6581: gaussian_noise : bool, default=False
6582: If `True`, adds Gaussian noise to the data. Otherwise, replaces
6583: values with NaN or the specified missing value.
6584:
6585: cat_missing_value : scalar, default=pd.NA
6586: The value to use for missing data in categorical columns. By
6587: default, `pd.NA` is used.
6588:
6589: Returns
6590: -------
6591: pandas.DataFrame
6592: A DataFrame with NaN or specified missing values added.
6593:
6594: Notes
6595: -----
6596: The function modifies the DataFrame by either adding Gaussian noise
6597: to numerical columns or replacing a percentage of values in each
6598: column with NaN or a specified missing value.
6599:
6600: The Gaussian noise is added according to the formula:
6601:
6602: .. math:: \text{new_value} = \text{original_value} + \mathcal{N}(0, \text{noise})
6603:
6604: where :math:`\mathcal{N}(0, \text{noise})` represents a normal
6605: distribution with mean 0 and standard deviation equal to `noise`.
6606:
6607: Examples
6608: --------
6609: >>> from gofast.tools.coreutils import add_noises_to
6610: >>> import pandas as pd
6611: >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': ['x', 'y', 'z']})
6612: >>> new_df = add_noises_to(df, noise=0.2)
6613: >>> new_df
6614: A B
6615: 0 1.0 <NA>
6616: 1 NaN y
6617: 2 3.0 <NA>
6618:
6619: >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
6620: >>> new_df = add_noises_to(df, noise=0.1, gaussian_noise=True)
6621: >>> new_df
6622: A B
6623: 0 1.063292 3.986400
6624: 1 2.103962 4.984292
6625: 2 2.856601 6.017380
6626:
6627: See Also
6628: --------
6629: pandas.DataFrame : Two-dimensional, size-mutable, potentially
6630: heterogeneous tabular data.
6631: numpy.random.normal : Draw random samples from a normal
6632: (Gaussian) distribution.
6633:
6634: References
6635: ----------
6636: .. [1] Harris, C. R., Millman, K. J., van der Walt, S. J., et al.
6637: (2020). Array programming with NumPy. Nature, 585(7825),
6638: 357-362.
6639: """
6640:
+6641: is_frame = isinstance (data, pd.DataFrame )
__Pyx_TraceLine(6641,0,__PYX_ERR(0, 6641, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_data, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 6641, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_is_frame = __pyx_t_3;
+6642: if not is_frame:
__Pyx_TraceLine(6642,0,__PYX_ERR(0, 6642, __pyx_L1_error)) __pyx_t_3 = (!__pyx_v_is_frame); if (__pyx_t_3) { /* … */ }
+6643: data = pd.DataFrame(data )
__Pyx_TraceLine(6643,0,__PYX_ERR(0, 6643, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6643, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
6644:
+6645: np.random.seed(seed)
__Pyx_TraceLine(6645,0,__PYX_ERR(0, 6645, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_seed); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_seed}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6646: if noise is None:
__Pyx_TraceLine(6646,0,__PYX_ERR(0, 6646, __pyx_L1_error)) __pyx_t_3 = (__pyx_cur_scope->__pyx_v_noise == Py_None); if (__pyx_t_3) { /* … */ }
+6647: return data
__Pyx_TraceLine(6647,0,__PYX_ERR(0, 6647, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
+6648: noise, gaussian_noise = _parse_gaussian_noise (noise )
__Pyx_TraceLine(6648,0,__PYX_ERR(0, 6648, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_parse_gaussian_noise); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_noise}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 6648, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6648, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); index = 0; __pyx_t_4 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) __PYX_ERR(0, 6648, __pyx_L1_error) __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_unpacking_done; __pyx_L5_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 6648, __pyx_L1_error) __pyx_L6_unpacking_done:; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_gaussian_noise, __pyx_t_1); __pyx_t_1 = 0;
6649:
+6650: if gaussian_noise:
__Pyx_TraceLine(6650,0,__PYX_ERR(0, 6650, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_gaussian_noise); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 6650, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
6651: # Add Gaussian noise to numerical columns only
+6652: def add_gaussian_noise(column):
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13add_noises_to_1add_gaussian_noise(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_13add_noises_to_1add_gaussian_noise = {"add_gaussian_noise", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_13add_noises_to_1add_gaussian_noise, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13add_noises_to_1add_gaussian_noise(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_column = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("add_gaussian_noise (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_column,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_column)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6652, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "add_gaussian_noise") < 0)) __PYX_ERR(0, 6652, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_column = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("add_gaussian_noise", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6652, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.add_noises_to.add_gaussian_noise", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_13add_noises_to_add_gaussian_noise(__pyx_self, __pyx_v_column);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_13add_noises_to_add_gaussian_noise(PyObject *__pyx_self, PyObject *__pyx_v_column) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_25_add_noises_to *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("add_gaussian_noise", __pyx_f[0], 6652, 0, __PYX_ERR(0, 6652, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.add_noises_to.add_gaussian_noise", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__249 = PyTuple_Pack(1, __pyx_n_s_column); if (unlikely(!__pyx_tuple__249)) __PYX_ERR(0, 6652, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__249);
__Pyx_GIVEREF(__pyx_tuple__249);
/* … */
__Pyx_TraceLine(6652,0,__PYX_ERR(0, 6652, __pyx_L1_error))
__pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_13add_noises_to_1add_gaussian_noise, 0, __pyx_n_s_add_noises_to_locals_add_gaussia, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__250)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6652, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_v_add_gaussian_noise = __pyx_t_2;
__pyx_t_2 = 0;
__pyx_codeobj__250 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__249, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_add_gaussian_noise, 6652, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__250)) __PYX_ERR(0, 6652, __pyx_L1_error)
+6653: if pd.api.types.is_numeric_dtype(column):
__Pyx_TraceLine(6653,0,__PYX_ERR(0, 6653, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_api); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_numeric_dtype_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_column}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6653, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
+6654: return column + np.random.normal(0, noise, size=column.shape)
__Pyx_TraceLine(6654,0,__PYX_ERR(0, 6654, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_normal); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_cur_scope->__pyx_v_noise)) { __Pyx_RaiseClosureNameError("noise"); __PYX_ERR(0, 6654, __pyx_L1_error) } __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0)) __PYX_ERR(0, 6654, __pyx_L1_error); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_noise); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_noise)) __PYX_ERR(0, 6654, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_column, __pyx_n_s_shape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_size, __pyx_t_6) < 0) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyNumber_Add(__pyx_v_column, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+6655: return column
__Pyx_TraceLine(6655,0,__PYX_ERR(0, 6655, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_column); __pyx_r = __pyx_v_column; goto __pyx_L0;
6656:
+6657: noise_data = data.apply(add_gaussian_noise)
__Pyx_TraceLine(6657,0,__PYX_ERR(0, 6657, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_apply); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_add_gaussian_noise}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_noise_data = __pyx_t_2; __pyx_t_2 = 0;
6658:
+6659: if not is_frame:
__Pyx_TraceLine(6659,0,__PYX_ERR(0, 6659, __pyx_L1_error)) __pyx_t_3 = (!__pyx_v_is_frame); if (__pyx_t_3) { /* … */ }
+6660: noise_data = np.asarray(noise_data)
__Pyx_TraceLine(6660,0,__PYX_ERR(0, 6660, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_noise_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_noise_data, __pyx_t_2); __pyx_t_2 = 0;
+6661: return noise_data
__Pyx_TraceLine(6661,0,__PYX_ERR(0, 6661, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_noise_data); __pyx_r = __pyx_v_noise_data; goto __pyx_L0;
6662: else:
6663: # Replace values with NaN or specified missing value
+6664: df_with_nan = data.copy()
__Pyx_TraceLine(6664,0,__PYX_ERR(0, 6664, __pyx_L1_error)) /*else*/ { __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_df_with_nan = __pyx_t_2; __pyx_t_2 = 0;
+6665: nan_count_per_column = int(noise * len(df_with_nan))
__Pyx_TraceLine(6665,0,__PYX_ERR(0, 6665, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_df_with_nan); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6665, __pyx_L1_error) __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6665, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyNumber_Multiply(__pyx_cur_scope->__pyx_v_noise, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6665, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6665, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_nan_count_per_column = __pyx_t_2; __pyx_t_2 = 0;
6666:
+6667: for column in df_with_nan.columns:
__Pyx_TraceLine(6667,0,__PYX_ERR(0, 6667, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df_with_nan, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6667, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6667, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 6667, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6667, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 6667, __pyx_L1_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6667, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6667, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_v_column, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(6667,0,__PYX_ERR(0, 6667, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+6668: nan_indices = random.sample(range(len(df_with_nan)), nan_count_per_column)
__Pyx_TraceLine(6668,0,__PYX_ERR(0, 6668, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_random); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6668, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sample); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6668, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = PyObject_Length(__pyx_v_df_with_nan); if (unlikely(__pyx_t_10 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6668, __pyx_L1_error) __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6668, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6668, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_t_11, __pyx_v_nan_count_per_column}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6668, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_XDECREF_SET(__pyx_v_nan_indices, __pyx_t_2); __pyx_t_2 = 0;
+6669: if pd.api.types.is_numeric_dtype(df_with_nan[column]):
__Pyx_TraceLine(6669,0,__PYX_ERR(0, 6669, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_api); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_types); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_is_numeric_dtype_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_df_with_nan, __pyx_v_column); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_6}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 6669, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L11; }
+6670: df_with_nan.loc[nan_indices, column] = np.nan
__Pyx_TraceLine(6670,0,__PYX_ERR(0, 6670, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_df_with_nan, __pyx_n_s_loc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6670, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_nan_indices); __Pyx_GIVEREF(__pyx_v_nan_indices); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_nan_indices)) __PYX_ERR(0, 6670, __pyx_L1_error); __Pyx_INCREF(__pyx_v_column); __Pyx_GIVEREF(__pyx_v_column); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_column)) __PYX_ERR(0, 6670, __pyx_L1_error); if (unlikely((PyObject_SetItem(__pyx_t_2, __pyx_t_6, __pyx_t_11) < 0))) __PYX_ERR(0, 6670, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
6671: else:
+6672: df_with_nan.loc[nan_indices, column] = cat_missing_value
__Pyx_TraceLine(6672,0,__PYX_ERR(0, 6672, __pyx_L1_error)) /*else*/ { __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_df_with_nan, __pyx_n_s_loc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6672, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_nan_indices); __Pyx_GIVEREF(__pyx_v_nan_indices); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_nan_indices)) __PYX_ERR(0, 6672, __pyx_L1_error); __Pyx_INCREF(__pyx_v_column); __Pyx_GIVEREF(__pyx_v_column); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_column)) __PYX_ERR(0, 6672, __pyx_L1_error); if (unlikely((PyObject_SetItem(__pyx_t_11, __pyx_t_6, __pyx_v_cat_missing_value) < 0))) __PYX_ERR(0, 6672, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_L11:;
6673:
+6674: if not is_frame:
__Pyx_TraceLine(6674,0,__PYX_ERR(0, 6674, __pyx_L1_error)) __pyx_t_3 = (!__pyx_v_is_frame); if (__pyx_t_3) { /* … */ }
+6675: df_with_nan = df_with_nan.values
__Pyx_TraceLine(6675,0,__PYX_ERR(0, 6675, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_df_with_nan, __pyx_n_s_values); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6675, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_df_with_nan, __pyx_t_4); __pyx_t_4 = 0;
6676:
+6677: return df_with_nan
__Pyx_TraceLine(6677,0,__PYX_ERR(0, 6677, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_df_with_nan); __pyx_r = __pyx_v_df_with_nan; goto __pyx_L0; }
6678:
+6679: def _parse_gaussian_noise(noise):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_206_parse_gaussian_noise(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_205_parse_gaussian_noise, "\n Parses the noise parameter to determine if Gaussian noise should be used\n and extracts the noise level if specified.\n\n Parameters\n ----------\n noise : str, float, or None\n The noise parameter to be parsed. Can be a string specifying Gaussian\n noise with an optional noise level, a float, or None.\n\n Returns\n -------\n tuple\n A tuple containing:\n - float: The noise level.\n - bool: Whether Gaussian noise should be used.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import _parse_gaussian_noise\n >>> _parse_gaussian_noise('0.1gaussian')\n (0.1, True)\n >>> _parse_gaussian_noise('gaussian0.1')\n (0.1, True)\n >>> _parse_gaussian_noise('gaussian_0.1')\n (0.1, True)\n >>> _parse_gaussian_noise('gaussian10%')\n (0.1, True)\n >>> _parse_gaussian_noise('gaussian 10 %')\n (0.1, True)\n >>> _parse_gaussian_noise(0.05)\n (0.05, False)\n >>> _parse_gaussian_noise(None)\n (0.1, False)\n >>> _parse_gaussian_noise('invalid')\n Traceback (most recent call last):\n ...\n ValueError: Invalid noise value: invalid\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_206_parse_gaussian_noise = {"_parse_gaussian_noise", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_206_parse_gaussian_noise, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_205_parse_gaussian_noise}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_206_parse_gaussian_noise(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_noise = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_parse_gaussian_noise (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_noise,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_noise)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6679, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_parse_gaussian_noise") < 0)) __PYX_ERR(0, 6679, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_noise = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_parse_gaussian_noise", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6679, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._parse_gaussian_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_205_parse_gaussian_noise(__pyx_self, __pyx_v_noise); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_21_parse_gaussian_noise_2generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_205_parse_gaussian_noise(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_noise) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise *__pyx_cur_scope; int __pyx_v_gaussian_noise; double __pyx_v_default_noise; PyObject *__pyx_v_orig_noise = NULL; PyObject *__pyx_v_gaussian_keywords = NULL; double __pyx_v_noise_level; PyObject *__pyx_gb_6gofast_5tools_9coreutils_21_parse_gaussian_noise_2generator10 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__251) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 6679, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("_parse_gaussian_noise", __pyx_f[0], 6679, 0, __PYX_ERR(0, 6679, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_noise = __pyx_v_noise; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_noise); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils._parse_gaussian_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_orig_noise); __Pyx_XDECREF(__pyx_v_gaussian_keywords); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_21_parse_gaussian_noise_2generator10); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__501 = PyTuple_Pack(8, __pyx_n_s_noise, __pyx_n_s_gaussian_noise, __pyx_n_s_default_noise, __pyx_n_s_orig_noise, __pyx_n_s_gaussian_keywords, __pyx_n_s_noise_level, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__501)) __PYX_ERR(0, 6679, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__501); __Pyx_GIVEREF(__pyx_tuple__501); /* … */ __Pyx_TraceLine(6679,0,__PYX_ERR(0, 6679, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_206_parse_gaussian_noise, 0, __pyx_n_s_parse_gaussian_noise, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__251)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_parse_gaussian_noise, __pyx_t_8) < 0) __PYX_ERR(0, 6679, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__251 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__501, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parse_gaussian_noise, 6679, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__251)) __PYX_ERR(0, 6679, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise { PyObject_HEAD PyObject *__pyx_v_noise; };
6680: """
6681: Parses the noise parameter to determine if Gaussian noise should be used
6682: and extracts the noise level if specified.
6683:
6684: Parameters
6685: ----------
6686: noise : str, float, or None
6687: The noise parameter to be parsed. Can be a string specifying Gaussian
6688: noise with an optional noise level, a float, or None.
6689:
6690: Returns
6691: -------
6692: tuple
6693: A tuple containing:
6694: - float: The noise level.
6695: - bool: Whether Gaussian noise should be used.
6696:
6697: Examples
6698: --------
6699: >>> from gofast.tools.coreutils import _parse_gaussian_noise
6700: >>> _parse_gaussian_noise('0.1gaussian')
6701: (0.1, True)
6702: >>> _parse_gaussian_noise('gaussian0.1')
6703: (0.1, True)
6704: >>> _parse_gaussian_noise('gaussian_0.1')
6705: (0.1, True)
6706: >>> _parse_gaussian_noise('gaussian10%')
6707: (0.1, True)
6708: >>> _parse_gaussian_noise('gaussian 10 %')
6709: (0.1, True)
6710: >>> _parse_gaussian_noise(0.05)
6711: (0.05, False)
6712: >>> _parse_gaussian_noise(None)
6713: (0.1, False)
6714: >>> _parse_gaussian_noise('invalid')
6715: Traceback (most recent call last):
6716: ...
6717: ValueError: Invalid noise value: invalid
6718: """
+6719: gaussian_noise = False
__Pyx_TraceLine(6719,0,__PYX_ERR(0, 6719, __pyx_L1_error)) __pyx_v_gaussian_noise = 0;
+6720: default_noise = 0.1
__Pyx_TraceLine(6720,0,__PYX_ERR(0, 6720, __pyx_L1_error)) __pyx_v_default_noise = 0.1;
6721:
+6722: if isinstance(noise, str):
__Pyx_TraceLine(6722,0,__PYX_ERR(0, 6722, __pyx_L1_error)) __pyx_t_1 = __pyx_cur_scope->__pyx_v_noise; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyUnicode_Check(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L3; }
+6723: orig_noise = noise
__Pyx_TraceLine(6723,0,__PYX_ERR(0, 6723, __pyx_L1_error)) __Pyx_INCREF(__pyx_cur_scope->__pyx_v_noise); __pyx_v_orig_noise = __pyx_cur_scope->__pyx_v_noise;
+6724: noise = noise.lower()
__Pyx_TraceLine(6724,0,__PYX_ERR(0, 6724, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_noise, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
+6725: gaussian_keywords = ["gaussian", "gauss"]
__Pyx_TraceLine(6725,0,__PYX_ERR(0, 6725, __pyx_L1_error)) __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_u_gaussian); __Pyx_GIVEREF(__pyx_n_u_gaussian); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_gaussian)) __PYX_ERR(0, 6725, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_gauss); __Pyx_GIVEREF(__pyx_n_u_gauss); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_gauss)) __PYX_ERR(0, 6725, __pyx_L1_error); __pyx_v_gaussian_keywords = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
6726:
+6727: if any(keyword in noise for keyword in gaussian_keywords):
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_21_parse_gaussian_noise_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_27_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_27_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_27_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_27_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_27_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 6727, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise *) __pyx_self;
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_21_parse_gaussian_noise_2generator10, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_parse_gaussian_noise_locals_gen, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 6727, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils._parse_gaussian_noise.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_21_parse_gaussian_noise_2generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6727, __pyx_L1_error)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 6727, __pyx_L1_error) }
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
for (;;) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6727, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 6727, __pyx_L1_error)
#else
__pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6727, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_keyword);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_keyword, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_noise)) { __Pyx_RaiseClosureNameError("noise"); __PYX_ERR(0, 6727, __pyx_L1_error) }
__pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_keyword, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_noise, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 6727, __pyx_L1_error)
if (__pyx_t_4) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(6727,0,__PYX_ERR(0, 6727, __pyx_L1_error))
__pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_21_parse_gaussian_noise_genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_gaussian_keywords); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6727, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6727, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 6727, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (__pyx_t_2) {
/* … */
goto __pyx_L4;
}
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_27_genexpr {
PyObject_HEAD
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_26__parse_gaussian_noise *__pyx_outer_scope;
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_keyword;
};
+6728: gaussian_noise = True
__Pyx_TraceLine(6728,0,__PYX_ERR(0, 6728, __pyx_L1_error)) __pyx_v_gaussian_noise = 1;
+6729: noise = re.sub(r'[^\d.%]', '', noise) # Remove non-numeric and non-'%' characters
__Pyx_TraceLine(6729,0,__PYX_ERR(0, 6729, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_kp_u_d_4, __pyx_kp_u__22, __pyx_cur_scope->__pyx_v_noise}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 3+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
+6730: noise = re.sub(r'%', '', noise) # Remove '%' if present
__Pyx_TraceLine(6730,0,__PYX_ERR(0, 6730, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_re); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sub); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_kp_u__203, __pyx_kp_u__22, __pyx_cur_scope->__pyx_v_noise}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 3+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6730, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
6731:
+6732: try:
__Pyx_TraceLine(6732,0,__PYX_ERR(0, 6732, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L10_try_end:; }
+6733: noise_level = float(noise) / 100 if '%' in orig_noise else float(noise)
__Pyx_TraceLine(6733,0,__PYX_ERR(0, 6733, __pyx_L5_error)) __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_kp_u__203, __pyx_v_orig_noise, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 6733, __pyx_L5_error) if (__pyx_t_2) { __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_cur_scope->__pyx_v_noise); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 6733, __pyx_L5_error) __pyx_t_9 = (__pyx_t_10 / 100.0); } else { __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_cur_scope->__pyx_v_noise); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 6733, __pyx_L5_error) __pyx_t_9 = __pyx_t_10; } __pyx_v_noise_level = __pyx_t_9;
+6734: noise = noise_level if noise_level else default_noise
__Pyx_TraceLine(6734,0,__PYX_ERR(0, 6734, __pyx_L5_error)) __pyx_t_2 = (__pyx_v_noise_level != 0); if (__pyx_t_2) { __pyx_t_1 = PyFloat_FromDouble(__pyx_v_noise_level); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6734, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } else { __pyx_t_1 = PyFloat_FromDouble(__pyx_v_default_noise); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6734, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; __pyx_t_1 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
+6735: except ValueError:
__Pyx_TraceLine(6735,0,__PYX_ERR(0, 6735, __pyx_L7_except_error)) __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils._parse_gaussian_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 6735, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_4);
+6736: noise = default_noise
__Pyx_TraceLine(6736,0,__PYX_ERR(0, 6736, __pyx_L7_except_error)) __pyx_t_11 = PyFloat_FromDouble(__pyx_v_default_noise); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6736, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L6_exception_handled; } goto __pyx_L7_except_error;
6737:
6738: else:
+6739: try:
__Pyx_TraceLine(6739,0,__PYX_ERR(0, 6739, __pyx_L1_error)) /*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L18_try_end; __pyx_L13_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L15_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_7, __pyx_t_6); goto __pyx_L1_error; __pyx_L18_try_end:; } } __pyx_L4:;
+6740: noise = float(noise)
__Pyx_TraceLine(6740,0,__PYX_ERR(0, 6740, __pyx_L13_error)) __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_cur_scope->__pyx_v_noise); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6740, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0;
+6741: except ValueError:
__Pyx_TraceLine(6741,0,__PYX_ERR(0, 6741, __pyx_L15_except_error)) __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils._parse_gaussian_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 6741, __pyx_L15_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_3);
+6742: raise ValueError(f"Invalid noise value: {noise}")
__Pyx_TraceLine(6742,0,__PYX_ERR(0, 6742, __pyx_L15_except_error)) __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_noise, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6742, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Invalid_noise_value, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6742, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6742, __pyx_L15_except_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 6742, __pyx_L15_except_error) } goto __pyx_L15_except_error;
+6743: elif noise is None:
__Pyx_TraceLine(6743,0,__PYX_ERR(0, 6743, __pyx_L1_error)) __pyx_t_2 = (__pyx_cur_scope->__pyx_v_noise == Py_None); if (__pyx_t_2) { /* … */ } __pyx_L3:;
+6744: noise = default_noise
__Pyx_TraceLine(6744,0,__PYX_ERR(0, 6744, __pyx_L1_error)) __pyx_t_3 = PyFloat_FromDouble(__pyx_v_default_noise); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6744, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
6745:
+6746: noise = validate_noise (noise )
__Pyx_TraceLine(6746,0,__PYX_ERR(0, 6746, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_validate_noise); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6746, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_noise}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6746, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_noise, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0;
6747:
+6748: return noise, gaussian_noise
__Pyx_TraceLine(6748,0,__PYX_ERR(0, 6748, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_gaussian_noise); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6748, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_noise); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_noise); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_noise)) __PYX_ERR(0, 6748, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3)) __PYX_ERR(0, 6748, __pyx_L1_error); __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
6749:
6750:
+6751: def nan_to_na(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_336__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 6751, 0, __PYX_ERR(0, 6751, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6751, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_cat_missing_value);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_cat_missing_value);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_cat_missing_value)) __PYX_ERR(0, 6751, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_nan_spec);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_nan_spec);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self)->__pyx_arg_nan_spec)) __PYX_ERR(0, 6751, __pyx_L1_error);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6751, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 6751, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 6751, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_208nan_to_na(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_207nan_to_na, "\n Converts specified NaN values in categorical columns of a pandas \n DataFrame or Series to `pd.NA` or another specified missing value.\n\n Parameters\n ----------\n data : pandas.DataFrame or pandas.Series\n The input DataFrame or Series in which specified NaN values in \n categorical columns will be converted.\n \n cat_missing_value : scalar, default=pd.NA\n The value to use for missing data in categorical columns. By \n default, `pd.NA` is used. This ensures that categorical columns \n do not contain `np.nan` values, which can cause type \n inconsistencies.\n\n nan_spec : scalar, default=np.nan\n The value that is treated as NaN in the input data. By default, \n `np.nan` is used. This allows flexibility in specifying what is \n considered as NaN.\n\n Returns\n -------\n pandas.DataFrame or pandas.Series\n The DataFrame or Series with specified NaN values in categorical \n columns converted to the specified missing value.\n\n Notes\n -----\n This function ensures consistency in the representation of missing \n values in categorical columns, avoiding issues that arise from the \n presence of specified NaN values in such columns.\n\n The conversion follows the logic:\n \n .. math:: \n \text{If column is categorical and contains `nan_spec`} \n \rightarrow \text{Replace `nan_spec` with `cat_missing_value`}\n\n Examples\n --------\n >>> from gofast.tools.coreutils import nan_to_na\n >>> import pandas as pd\n >>> import numpy as np\n >>> df = pd.DataFrame({'A': [1.0, 2.0, np.nan], 'B': ['x', np.nan, 'z']})\n >>> df['B'] = df['B'].astype('category')\n >>> df = nan_to_na(df)\n >>> df\n A B\n 0 1.0 x\n 1 2.0 <NA>\n 2 NaN z\n\n See Also\n --------\n pandas.DataFrame : Two-dimensional, size-mutable, potentially \n heterogeneous tabular data.\n pa""ndas.Series : One-dimensional ndarray with axis labels.\n numpy.nan : IEEE 754 floating point representation of Not a Number \n (NaN).\n\n References\n ----------\n .. [1] Harris, C. R., Millman, K. J., van der Walt, S. J., et al. \n (2020). Array programming with NumPy. Nature, 585(7825), \n 357-362.\n\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_208nan_to_na = {"nan_to_na", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_208nan_to_na, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_207nan_to_na};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_208nan_to_na(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_data = 0;
PyObject *__pyx_v_cat_missing_value = 0;
PyObject *__pyx_v_nan_spec = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("nan_to_na (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_cat_missing_value,&__pyx_n_s_nan_spec,0};
PyObject* values[3] = {0,0,0};
__pyx_defaults15 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_self);
values[1] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_cat_missing_value);
values[2] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_nan_spec);
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6751, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cat_missing_value);
if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6751, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (kw_args > 0) {
PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_nan_spec);
if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; }
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6751, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "nan_to_na") < 0)) __PYX_ERR(0, 6751, __pyx_L3_error)
}
} else {
switch (__pyx_nargs) {
case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2);
CYTHON_FALLTHROUGH;
case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_data = values[0];
__pyx_v_cat_missing_value = values[1];
__pyx_v_nan_spec = values[2];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("nan_to_na", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 6751, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.nan_to_na", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_207nan_to_na(__pyx_self, __pyx_v_data, __pyx_v_cat_missing_value, __pyx_v_nan_spec);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_207nan_to_na(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_cat_missing_value, PyObject *__pyx_v_nan_spec) {
PyObject *__pyx_v_has_nan_values = 0;
PyObject *__pyx_v_df_copy = NULL;
PyObject *__pyx_v_column = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__252)
__Pyx_TraceCall("nan_to_na", __pyx_f[0], 6751, 0, __PYX_ERR(0, 6751, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_AddTraceback("gofast.tools.coreutils.nan_to_na", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_has_nan_values);
__Pyx_XDECREF(__pyx_v_df_copy);
__Pyx_XDECREF(__pyx_v_column);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__502 = PyTuple_Pack(7, __pyx_n_s_data, __pyx_n_s_cat_missing_value, __pyx_n_s_nan_spec, __pyx_n_s_has_nan_values, __pyx_n_s_has_nan_values, __pyx_n_s_df_copy, __pyx_n_s_column); if (unlikely(!__pyx_tuple__502)) __PYX_ERR(0, 6751, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__502);
__Pyx_GIVEREF(__pyx_tuple__502);
/* … */
__Pyx_TraceLine(6751,0,__PYX_ERR(0, 6751, __pyx_L1_error))
__pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_208nan_to_na, 0, __pyx_n_s_nan_to_na, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__252)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6751, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_8, sizeof(__pyx_defaults15), 2)) __PYX_ERR(0, 6751, __pyx_L1_error)
__pyx_codeobj__252 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__502, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_nan_to_na, 6751, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__252)) __PYX_ERR(0, 6751, __pyx_L1_error)
6752: data,
+6753: cat_missing_value=pd.NA,
__Pyx_TraceLine(6753,0,__PYX_ERR(0, 6753, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_NA); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_t_8)->__pyx_arg_cat_missing_value = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
+6754: nan_spec=np.nan
__Pyx_TraceLine(6754,0,__PYX_ERR(0, 6754, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_nan); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults15, __pyx_t_8)->__pyx_arg_nan_spec = __pyx_t_5; __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_8, __pyx_pf_6gofast_5tools_9coreutils_336__defaults__); if (PyDict_SetItem(__pyx_d, __pyx_n_s_nan_to_na, __pyx_t_8) < 0) __PYX_ERR(0, 6751, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6755: ):
6756: """
6757: Converts specified NaN values in categorical columns of a pandas
6758: DataFrame or Series to `pd.NA` or another specified missing value.
6759:
6760: Parameters
6761: ----------
6762: data : pandas.DataFrame or pandas.Series
6763: The input DataFrame or Series in which specified NaN values in
6764: categorical columns will be converted.
6765:
6766: cat_missing_value : scalar, default=pd.NA
6767: The value to use for missing data in categorical columns. By
6768: default, `pd.NA` is used. This ensures that categorical columns
6769: do not contain `np.nan` values, which can cause type
6770: inconsistencies.
6771:
6772: nan_spec : scalar, default=np.nan
6773: The value that is treated as NaN in the input data. By default,
6774: `np.nan` is used. This allows flexibility in specifying what is
6775: considered as NaN.
6776:
6777: Returns
6778: -------
6779: pandas.DataFrame or pandas.Series
6780: The DataFrame or Series with specified NaN values in categorical
6781: columns converted to the specified missing value.
6782:
6783: Notes
6784: -----
6785: This function ensures consistency in the representation of missing
6786: values in categorical columns, avoiding issues that arise from the
6787: presence of specified NaN values in such columns.
6788:
6789: The conversion follows the logic:
6790:
6791: .. math::
6792: \text{If column is categorical and contains `nan_spec`}
6793: \rightarrow \text{Replace `nan_spec` with `cat_missing_value`}
6794:
6795: Examples
6796: --------
6797: >>> from gofast.tools.coreutils import nan_to_na
6798: >>> import pandas as pd
6799: >>> import numpy as np
6800: >>> df = pd.DataFrame({'A': [1.0, 2.0, np.nan], 'B': ['x', np.nan, 'z']})
6801: >>> df['B'] = df['B'].astype('category')
6802: >>> df = nan_to_na(df)
6803: >>> df
6804: A B
6805: 0 1.0 x
6806: 1 2.0 <NA>
6807: 2 NaN z
6808:
6809: See Also
6810: --------
6811: pandas.DataFrame : Two-dimensional, size-mutable, potentially
6812: heterogeneous tabular data.
6813: pandas.Series : One-dimensional ndarray with axis labels.
6814: numpy.nan : IEEE 754 floating point representation of Not a Number
6815: (NaN).
6816:
6817: References
6818: ----------
6819: .. [1] Harris, C. R., Millman, K. J., van der Walt, S. J., et al.
6820: (2020). Array programming with NumPy. Nature, 585(7825),
6821: 357-362.
6822:
6823: """
+6824: if not isinstance (data, (pd.Series, pd.DataFrame)):
__Pyx_TraceLine(6824,0,__PYX_ERR(0, 6824, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_t_2); if (!__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_t_3); __pyx_t_4 = __pyx_t_5; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (!__pyx_t_4); if (unlikely(__pyx_t_5)) { /* … */ }
+6825: raise ValueError("Input must be a pandas DataFrame or Series."
__Pyx_TraceLine(6825,0,__PYX_ERR(0, 6825, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_Input_must_be_a_pandas_DataFrame); __pyx_t_6 += 48; __Pyx_GIVEREF(__pyx_kp_u_Input_must_be_a_pandas_DataFrame); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_Input_must_be_a_pandas_DataFrame); /* … */ __Pyx_TraceLine(6825,0,__PYX_ERR(0, 6825, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 6825, __pyx_L1_error)
+6826: f" Got {type(data).__name__!r} instead.")
__Pyx_TraceLine(6826,0,__PYX_ERR(0, 6826, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_3), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6826, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_kp_u_instead); __pyx_t_6 += 9; __Pyx_GIVEREF(__pyx_kp_u_instead); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_instead);
6827:
+6828: def has_nan_values(series, nan_spec):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_9nan_to_na_1has_nan_values(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_9nan_to_na_has_nan_values, "Check if nan_spec exists in the series."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_9nan_to_na_1has_nan_values = {"has_nan_values", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_9nan_to_na_1has_nan_values, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_9nan_to_na_has_nan_values}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_9nan_to_na_1has_nan_values(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_series = 0; PyObject *__pyx_v_nan_spec = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("has_nan_values (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_series,&__pyx_n_s_nan_spec,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_series)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6828, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_nan_spec)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6828, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("has_nan_values", 1, 2, 2, 1); __PYX_ERR(0, 6828, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "has_nan_values") < 0)) __PYX_ERR(0, 6828, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_series = values[0]; __pyx_v_nan_spec = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("has_nan_values", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 6828, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.nan_to_na.has_nan_values", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_9nan_to_na_has_nan_values(__pyx_self, __pyx_v_series, __pyx_v_nan_spec); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_9nan_to_na_has_nan_values(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_series, PyObject *__pyx_v_nan_spec) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("has_nan_values", __pyx_f[0], 6828, 0, __PYX_ERR(0, 6828, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.nan_to_na.has_nan_values", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__253 = PyTuple_Pack(2, __pyx_n_s_series, __pyx_n_s_nan_spec); if (unlikely(!__pyx_tuple__253)) __PYX_ERR(0, 6828, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__253); __Pyx_GIVEREF(__pyx_tuple__253); /* … */ __Pyx_TraceLine(6828,0,__PYX_ERR(0, 6828, __pyx_L1_error)) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_9nan_to_na_1has_nan_values, 0, __pyx_n_s_nan_to_na_locals_has_nan_values, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__254)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_has_nan_values = __pyx_t_2; __pyx_t_2 = 0; __pyx_codeobj__254 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__253, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_has_nan_values, 6828, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__254)) __PYX_ERR(0, 6828, __pyx_L1_error)
6829: """Check if nan_spec exists in the series."""
+6830: return series.isin([nan_spec]).any()
__Pyx_TraceLine(6830,0,__PYX_ERR(0, 6830, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_series, __pyx_n_s_isin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_nan_spec); __Pyx_GIVEREF(__pyx_v_nan_spec); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_nan_spec)) __PYX_ERR(0, 6830, __pyx_L1_error); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_any); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6830, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
6831:
+6832: if isinstance(data, pd.Series):
__Pyx_TraceLine(6832,0,__PYX_ERR(0, 6832, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Series); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_t_1); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 6832, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
+6833: if has_nan_values(data, nan_spec):
__Pyx_TraceLine(6833,0,__PYX_ERR(0, 6833, __pyx_L1_error)) __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_9nan_to_na_has_nan_values(__pyx_v_has_nan_values, __pyx_v_data, __pyx_v_nan_spec); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6833, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6833, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
+6834: if pd.api.types.is_categorical_dtype(data):
__Pyx_TraceLine(6834,0,__PYX_ERR(0, 6834, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_api); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_types); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_is_categorical_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_data}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6834, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6834, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
+6835: return data.replace({nan_spec: cat_missing_value})
__Pyx_TraceLine(6835,0,__PYX_ERR(0, 6835, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6835, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6835, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_v_nan_spec, __pyx_v_cat_missing_value) < 0) __PYX_ERR(0, 6835, __pyx_L1_error) __pyx_t_9 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_2}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6835, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+6836: return data
__Pyx_TraceLine(6836,0,__PYX_ERR(0, 6836, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_data); __pyx_r = __pyx_v_data; goto __pyx_L0;
6837:
+6838: elif isinstance(data, pd.DataFrame):
__Pyx_TraceLine(6838,0,__PYX_ERR(0, 6838, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6838, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_t_3); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 6838, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { /* … */ }
+6839: df_copy = data.copy()
__Pyx_TraceLine(6839,0,__PYX_ERR(0, 6839, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_copy); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6839, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_df_copy = __pyx_t_3; __pyx_t_3 = 0;
+6840: for column in df_copy.columns:
__Pyx_TraceLine(6840,0,__PYX_ERR(0, 6840, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_df_copy, __pyx_n_s_columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_6 = 0; __pyx_t_10 = NULL; } else { __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6840, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_1))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6840, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 6840, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6840, __pyx_L1_error) #endif if (__pyx_t_6 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6); __Pyx_INCREF(__pyx_t_3); __pyx_t_6++; if (unlikely((0 < 0))) __PYX_ERR(0, 6840, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_10(__pyx_t_1); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6840, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_column, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(6840,0,__PYX_ERR(0, 6840, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+6841: if has_nan_values(df_copy[column], nan_spec):
__Pyx_TraceLine(6841,0,__PYX_ERR(0, 6841, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_df_copy, __pyx_v_column); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __pyx_pf_6gofast_5tools_9coreutils_9nan_to_na_has_nan_values(__pyx_v_has_nan_values, __pyx_t_3, __pyx_v_nan_spec); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6841, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6841, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_5) { /* … */ }
+6842: if pd.api.types.is_categorical_dtype(df_copy[column]):
__Pyx_TraceLine(6842,0,__PYX_ERR(0, 6842, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_api); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_categorical_dtype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_df_copy, __pyx_v_column); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6842, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_5) { /* … */ }
+6843: df_copy[column] = df_copy[column].replace({nan_spec: cat_missing_value})
__Pyx_TraceLine(6843,0,__PYX_ERR(0, 6843, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_df_copy, __pyx_v_column); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6843, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6843, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6843, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (PyDict_SetItem(__pyx_t_9, __pyx_v_nan_spec, __pyx_v_cat_missing_value) < 0) __PYX_ERR(0, 6843, __pyx_L1_error) __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_t_9}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6843, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_df_copy, __pyx_v_column, __pyx_t_2) < 0))) __PYX_ERR(0, 6843, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+6844: return df_copy
__Pyx_TraceLine(6844,0,__PYX_ERR(0, 6844, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_df_copy); __pyx_r = __pyx_v_df_copy; goto __pyx_L0;
6845:
+6846: def validate_noise(noise):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_210validate_noise(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_209validate_noise, "\n Validates the `noise` parameter and returns either the noise value\n as a float or the string 'gaussian'.\n\n Parameters\n ----------\n noise : str or float or None\n The noise parameter to be validated. It can be the string\n 'gaussian', a float value, or None.\n\n Returns\n -------\n float or str\n The validated noise value as a float or the string 'gaussian'.\n\n Raises\n ------\n ValueError\n If the `noise` parameter is a string other than 'gaussian' or\n cannot be converted to a float.\n\n Examples\n --------\n >>> validate_noise('gaussian')\n 'gaussian'\n >>> validate_noise(0.1)\n 0.1\n >>> validate_noise(None)\n None\n >>> validate_noise('0.2')\n 0.2\n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_210validate_noise = {"validate_noise", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_210validate_noise, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_209validate_noise}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_210validate_noise(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_noise = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("validate_noise (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_noise,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_noise)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6846, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "validate_noise") < 0)) __PYX_ERR(0, 6846, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_noise = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("validate_noise", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6846, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.validate_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_209validate_noise(__pyx_self, __pyx_v_noise); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_209validate_noise(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_noise) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__255) __Pyx_TraceCall("validate_noise", __pyx_f[0], 6846, 0, __PYX_ERR(0, 6846, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_noise); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.validate_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_noise); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__503 = PyTuple_Pack(1, __pyx_n_s_noise); if (unlikely(!__pyx_tuple__503)) __PYX_ERR(0, 6846, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__503); __Pyx_GIVEREF(__pyx_tuple__503); /* … */ __Pyx_TraceLine(6846,0,__PYX_ERR(0, 6846, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_210validate_noise, 0, __pyx_n_s_validate_noise, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__255)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6846, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_noise, __pyx_t_8) < 0) __PYX_ERR(0, 6846, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__255 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__503, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_noise, 6846, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__255)) __PYX_ERR(0, 6846, __pyx_L1_error)
6847: """
6848: Validates the `noise` parameter and returns either the noise value
6849: as a float or the string 'gaussian'.
6850:
6851: Parameters
6852: ----------
6853: noise : str or float or None
6854: The noise parameter to be validated. It can be the string
6855: 'gaussian', a float value, or None.
6856:
6857: Returns
6858: -------
6859: float or str
6860: The validated noise value as a float or the string 'gaussian'.
6861:
6862: Raises
6863: ------
6864: ValueError
6865: If the `noise` parameter is a string other than 'gaussian' or
6866: cannot be converted to a float.
6867:
6868: Examples
6869: --------
6870: >>> validate_noise('gaussian')
6871: 'gaussian'
6872: >>> validate_noise(0.1)
6873: 0.1
6874: >>> validate_noise(None)
6875: None
6876: >>> validate_noise('0.2')
6877: 0.2
6878:
6879: """
+6880: if isinstance(noise, str):
__Pyx_TraceLine(6880,0,__PYX_ERR(0, 6880, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_noise); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+6881: if noise.lower() == 'gaussian':
__Pyx_TraceLine(6881,0,__PYX_ERR(0, 6881, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_noise, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6881, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6881, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_gaussian, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 6881, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+6882: return 'gaussian'
__Pyx_TraceLine(6882,0,__PYX_ERR(0, 6882, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_n_u_gaussian); __pyx_r = __pyx_n_u_gaussian; goto __pyx_L0;
6883: else:
+6884: try:
__Pyx_TraceLine(6884,0,__PYX_ERR(0, 6884, __pyx_L1_error)) /*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L10_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L10_try_end:; } }
+6885: noise = float(noise)
__Pyx_TraceLine(6885,0,__PYX_ERR(0, 6885, __pyx_L5_error)) __pyx_t_2 = __Pyx_PyNumber_Float(__pyx_v_noise); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6885, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF_SET(__pyx_v_noise, __pyx_t_2); __pyx_t_2 = 0;
+6886: except ValueError:
__Pyx_TraceLine(6886,0,__PYX_ERR(0, 6886, __pyx_L7_except_error)) __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils.validate_noise", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 6886, __pyx_L7_except_error) __Pyx_XGOTREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_4);
+6887: raise ValueError("The `noise` parameter accepts the string"
__Pyx_TraceLine(6887,0,__PYX_ERR(0, 6887, __pyx_L7_except_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__256, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6887, __pyx_L7_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 6887, __pyx_L7_except_error) } goto __pyx_L7_except_error; /* … */ __pyx_tuple__256 = PyTuple_Pack(1, __pyx_kp_u_The_noise_parameter_accepts_the); if (unlikely(!__pyx_tuple__256)) __PYX_ERR(0, 6887, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__256); __Pyx_GIVEREF(__pyx_tuple__256);
6888: " 'gaussian' or a float value.")
+6889: elif noise is not None:
__Pyx_TraceLine(6889,0,__PYX_ERR(0, 6889, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_noise != Py_None); if (__pyx_t_1) { /* … */ } __pyx_L3:;
+6890: noise = validate_ratio(noise, bounds=(0, 1), param_name='noise' )
__Pyx_TraceLine(6890,0,__PYX_ERR(0, 6890, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_validate_ratio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_noise); __Pyx_GIVEREF(__pyx_v_noise); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_noise)) __PYX_ERR(0, 6890, __pyx_L1_error); __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_bounds, __pyx_tuple__234) < 0) __PYX_ERR(0, 6890, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_param_name, __pyx_n_u_noise) < 0) __PYX_ERR(0, 6890, __pyx_L1_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_noise, __pyx_t_9); __pyx_t_9 = 0;
6891: # try:
6892: # except ValueError:
6893: # raise ValueError("The `noise` parameter must be convertible to a float.")
+6894: return noise
__Pyx_TraceLine(6894,0,__PYX_ERR(0, 6894, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_noise); __pyx_r = __pyx_v_noise; goto __pyx_L0;
6895:
+6896: def fancier_repr_formatter(obj, max_attrs=7):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_212fancier_repr_formatter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_211fancier_repr_formatter, "\n Generates a formatted string representation for any class object.\n\n Parameters:\n ----------\n obj : object\n The object for which the string representation is generated.\n\n max_attrs : int, optional\n Maximum number of attributes to display in the representation.\n\n Returns:\n -------\n str\n A string representation of the object.\n\n Examples:\n --------\n >>> from gofast.tools.coreutils import fancier_repr_formatter\n >>> class MyClass:\n >>> def __init__(self, a, b, c):\n >>> self.a = a\n >>> self.b = b\n >>> self.c = c\n >>> obj = MyClass(1, [1, 2, 3], 'hello')\n >>> print(fancier_repr_formatter(obj))\n MyClass(a=1, c='hello', ...)\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_212fancier_repr_formatter = {"fancier_repr_formatter", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_212fancier_repr_formatter, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_211fancier_repr_formatter}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_212fancier_repr_formatter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_max_attrs = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fancier_repr_formatter (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_max_attrs,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_7))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6896, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_attrs); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6896, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "fancier_repr_formatter") < 0)) __PYX_ERR(0, 6896, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_obj = values[0]; __pyx_v_max_attrs = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fancier_repr_formatter", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 6896, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.fancier_repr_formatter", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_211fancier_repr_formatter(__pyx_self, __pyx_v_obj, __pyx_v_max_attrs); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_211fancier_repr_formatter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_max_attrs) { PyObject *__pyx_v_attrs = NULL; PyObject *__pyx_v_displayed_attrs = NULL; PyObject *__pyx_v_attr_str = NULL; PyObject *__pyx_9genexpr69__pyx_v_name = NULL; PyObject *__pyx_9genexpr70__pyx_v_name = NULL; PyObject *__pyx_9genexpr70__pyx_v_value = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__257) __Pyx_TraceCall("fancier_repr_formatter", __pyx_f[0], 6896, 0, __PYX_ERR(0, 6896, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils.fancier_repr_formatter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_attrs); __Pyx_XDECREF(__pyx_v_displayed_attrs); __Pyx_XDECREF(__pyx_v_attr_str); __Pyx_XDECREF(__pyx_9genexpr69__pyx_v_name); __Pyx_XDECREF(__pyx_9genexpr70__pyx_v_name); __Pyx_XDECREF(__pyx_9genexpr70__pyx_v_value); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__504 = PyTuple_Pack(8, __pyx_n_s_obj, __pyx_n_s_max_attrs, __pyx_n_s_attrs, __pyx_n_s_displayed_attrs, __pyx_n_s_attr_str, __pyx_n_s_name_2, __pyx_n_s_name_2, __pyx_n_s_value); if (unlikely(!__pyx_tuple__504)) __PYX_ERR(0, 6896, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__504); __Pyx_GIVEREF(__pyx_tuple__504); __pyx_codeobj__257 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__504, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fancier_repr_formatter, 6896, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__257)) __PYX_ERR(0, 6896, __pyx_L1_error) /* … */ __Pyx_TraceLine(6896,0,__PYX_ERR(0, 6896, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_212fancier_repr_formatter, 0, __pyx_n_s_fancier_repr_formatter, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__257)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6896, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__505); if (PyDict_SetItem(__pyx_d, __pyx_n_s_fancier_repr_formatter, __pyx_t_8) < 0) __PYX_ERR(0, 6896, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__505 = PyTuple_Pack(1, ((PyObject *)__pyx_int_7)); if (unlikely(!__pyx_tuple__505)) __PYX_ERR(0, 6896, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__505); __Pyx_GIVEREF(__pyx_tuple__505);
6897: """
6898: Generates a formatted string representation for any class object.
6899:
6900: Parameters:
6901: ----------
6902: obj : object
6903: The object for which the string representation is generated.
6904:
6905: max_attrs : int, optional
6906: Maximum number of attributes to display in the representation.
6907:
6908: Returns:
6909: -------
6910: str
6911: A string representation of the object.
6912:
6913: Examples:
6914: --------
6915: >>> from gofast.tools.coreutils import fancier_repr_formatter
6916: >>> class MyClass:
6917: >>> def __init__(self, a, b, c):
6918: >>> self.a = a
6919: >>> self.b = b
6920: >>> self.c = c
6921: >>> obj = MyClass(1, [1, 2, 3], 'hello')
6922: >>> print(fancier_repr_formatter(obj))
6923: MyClass(a=1, c='hello', ...)
6924: """
+6925: attrs = [(name, getattr(obj, name)) for name in dir(obj)
__Pyx_TraceLine(6925,0,__PYX_ERR(0, 6925, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_Dir(__pyx_v_obj); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_3 = __pyx_t_2; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6925, __pyx_L5_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; for (;;) { if (likely(!__pyx_t_5)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6925, __pyx_L5_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 6925, __pyx_L5_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6925, __pyx_L5_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 6925, __pyx_L5_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_5(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 6925, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_9genexpr69__pyx_v_name, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(6925,0,__PYX_ERR(0, 6925, __pyx_L5_error)) __pyx_t_2 = __Pyx_GetAttr(__pyx_v_obj, __pyx_9genexpr69__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_9genexpr69__pyx_v_name); __Pyx_GIVEREF(__pyx_9genexpr69__pyx_v_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_9genexpr69__pyx_v_name)) __PYX_ERR(0, 6925, __pyx_L5_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2)) __PYX_ERR(0, 6925, __pyx_L5_error); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 6925, __pyx_L5_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(6925,0,__PYX_ERR(0, 6925, __pyx_L5_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr69__pyx_v_name); __pyx_9genexpr69__pyx_v_name = 0; goto __pyx_L13_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_9genexpr69__pyx_v_name); __pyx_9genexpr69__pyx_v_name = 0; goto __pyx_L1_error; __pyx_L13_exit_scope:; } /* exit inner scope */ __pyx_v_attrs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+6926: if not name.startswith('_') and
__Pyx_TraceLine(6926,0,__PYX_ERR(0, 6926, __pyx_L5_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr69__pyx_v_name, __pyx_n_s_startswith); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6926, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_n_u__8}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 1+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6926, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 6926, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_11 = (!__pyx_t_10); if (__pyx_t_11) { } else { __pyx_t_6 = __pyx_t_11; goto __pyx_L9_bool_binop_done; } /* … */ __Pyx_TraceLine(6926,0,__PYX_ERR(0, 6926, __pyx_L5_error)) if (__pyx_t_6) { /* … */ }
+6927: (isinstance(getattr(obj, name), str) or
__Pyx_TraceLine(6927,0,__PYX_ERR(0, 6927, __pyx_L5_error)) __pyx_t_2 = __Pyx_GetAttr(__pyx_v_obj, __pyx_9genexpr69__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6927, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = PyUnicode_Check(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (!__pyx_t_11) { } else { __pyx_t_6 = __pyx_t_11; goto __pyx_L9_bool_binop_done; }
+6928: not hasattr(getattr(obj, name), '__iter__'))]
__Pyx_TraceLine(6928,0,__PYX_ERR(0, 6928, __pyx_L5_error)) __pyx_t_2 = __Pyx_GetAttr(__pyx_v_obj, __pyx_9genexpr69__pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6928, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = __Pyx_HasAttr(__pyx_t_2, __pyx_n_u_iter); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 6928, __pyx_L5_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = (!__pyx_t_11); __pyx_t_6 = __pyx_t_10; __pyx_L9_bool_binop_done:;
6929:
+6930: displayed_attrs = attrs[:min(len(attrs), max_attrs)]
__Pyx_TraceLine(6930,0,__PYX_ERR(0, 6930, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_max_attrs); __pyx_t_1 = __pyx_v_max_attrs; __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_attrs); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6930, __pyx_L1_error) __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_7, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6930, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = __pyx_t_1; } else { __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __pyx_t_2; __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = (__pyx_t_1 == Py_None); if (__pyx_t_6) { __pyx_t_4 = PY_SSIZE_T_MAX; } else { __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 6930, __pyx_L1_error) __pyx_t_4 = __pyx_t_12; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_v_attrs, 0, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6930, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_displayed_attrs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+6931: attr_str = ', '.join([f'{name}={value!r}' for name, value in displayed_attrs])
__Pyx_TraceLine(6931,0,__PYX_ERR(0, 6931, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __pyx_v_displayed_attrs; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6931, __pyx_L16_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 6931, __pyx_L16_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_2); #endif if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 6931, __pyx_L16_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_7 = PyList_GET_ITEM(sequence, 0); __pyx_t_8 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); #else __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; __pyx_t_13 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_14 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); index = 0; __pyx_t_7 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_7)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); index = 1; __pyx_t_8 = __pyx_t_14(__pyx_t_13); if (unlikely(!__pyx_t_8)) goto __pyx_L19_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_13), 2) < 0) __PYX_ERR(0, 6931, __pyx_L16_error) __pyx_t_14 = NULL; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L20_unpacking_done; __pyx_L19_unpacking_failed:; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_14 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 6931, __pyx_L16_error) __pyx_L20_unpacking_done:; } __Pyx_XDECREF_SET(__pyx_9genexpr70__pyx_v_name, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_9genexpr70__pyx_v_value, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_12 = 0; __pyx_t_15 = 127; __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_9genexpr70__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_15; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__54); __pyx_t_12 += 1; __Pyx_GIVEREF(__pyx_kp_u__54); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_kp_u__54); __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_9genexpr70__pyx_v_value), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_15; __pyx_t_12 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_12, __pyx_t_15); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 6931, __pyx_L16_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr70__pyx_v_name); __pyx_9genexpr70__pyx_v_name = 0; __Pyx_XDECREF(__pyx_9genexpr70__pyx_v_value); __pyx_9genexpr70__pyx_v_value = 0; goto __pyx_L22_exit_scope; __pyx_L16_error:; __Pyx_XDECREF(__pyx_9genexpr70__pyx_v_name); __pyx_9genexpr70__pyx_v_name = 0; __Pyx_XDECREF(__pyx_9genexpr70__pyx_v_value); __pyx_9genexpr70__pyx_v_value = 0; goto __pyx_L1_error; __pyx_L22_exit_scope:; } /* exit inner scope */ __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__258, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6931, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_attr_str = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
6932:
6933: # Add ellipsis if there are more attributes than max_attrs
+6934: if len(attrs) > max_attrs:
__Pyx_TraceLine(6934,0,__PYX_ERR(0, 6934, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_attrs); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6934, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6934, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_v_max_attrs, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6934, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6934, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_6) { /* … */ }
+6935: attr_str += ', ...'
__Pyx_TraceLine(6935,0,__PYX_ERR(0, 6935, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyUnicode_ConcatInPlaceSafe(__pyx_v_attr_str, __pyx_kp_u__259); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6935, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_attr_str, ((PyObject*)__pyx_t_1)); __pyx_t_1 = 0;
6936:
+6937: return f'{obj.__class__.__name__}({attr_str})'
__Pyx_TraceLine(6937,0,__PYX_ERR(0, 6937, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_15 = 127; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_class); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_8, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_15; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__53); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__53); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__53); __pyx_t_3 = __Pyx_PyUnicode_Unicode(__pyx_v_attr_str); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_15; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__56); __pyx_t_4 += 1; __Pyx_GIVEREF(__pyx_kp_u__56); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__56); __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 4, __pyx_t_4, __pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6937, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
6938:
+6939: def generic_getattr(obj, name, default_value=None):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_214generic_getattr(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_213generic_getattr, "\n A generic attribute accessor for any class instance.\n\n This function attempts to retrieve an attribute from the given object.\n If the attribute is not found, it provides a meaningful error message.\n\n Parameters:\n ----------\n obj : object\n The object from which to retrieve the attribute.\n\n name : str\n The name of the attribute to retrieve.\n\n default_value : any, optional\n A default value to return if the attribute is not found. If None,\n an AttributeError will be raised.\n\n Returns:\n -------\n any\n The value of the retrieved attribute or the default value.\n\n Raises:\n ------\n AttributeError\n If the attribute is not found and no default value is provided.\n\n Examples:\n --------\n >>> from gofast.tools.coreutils import generic_getattr\n >>> class MyClass:\n >>> def __init__(self, a, b):\n >>> self.a = a\n >>> self.b = b\n >>> obj = MyClass(1, 2)\n >>> print(generic_getattr(obj, 'a')) # Prints: 1\n >>> print(generic_getattr(obj, 'c', 'default')) # Prints: 'default'\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_214generic_getattr = {"generic_getattr", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_214generic_getattr, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_213generic_getattr}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_214generic_getattr(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_name = 0; PyObject *__pyx_v_default_value = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("generic_getattr (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_name_2,&__pyx_n_s_default_value,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6939, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6939, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("generic_getattr", 0, 2, 3, 1); __PYX_ERR(0, 6939, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_default_value); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6939, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "generic_getattr") < 0)) __PYX_ERR(0, 6939, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_obj = values[0]; __pyx_v_name = values[1]; __pyx_v_default_value = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("generic_getattr", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 6939, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.generic_getattr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_213generic_getattr(__pyx_self, __pyx_v_obj, __pyx_v_name, __pyx_v_default_value); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_213generic_getattr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_name, PyObject *__pyx_v_default_value) { PyObject *__pyx_v_similar_attr = NULL; PyObject *__pyx_v_suggestion = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__260) __Pyx_TraceCall("generic_getattr", __pyx_f[0], 6939, 0, __PYX_ERR(0, 6939, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.generic_getattr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_similar_attr); __Pyx_XDECREF(__pyx_v_suggestion); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__506 = PyTuple_Pack(5, __pyx_n_s_obj, __pyx_n_s_name_2, __pyx_n_s_default_value, __pyx_n_s_similar_attr, __pyx_n_s_suggestion); if (unlikely(!__pyx_tuple__506)) __PYX_ERR(0, 6939, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__506); __Pyx_GIVEREF(__pyx_tuple__506); /* … */ __Pyx_TraceLine(6939,0,__PYX_ERR(0, 6939, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_214generic_getattr, 0, __pyx_n_s_generic_getattr, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__260)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6939, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__62); if (PyDict_SetItem(__pyx_d, __pyx_n_s_generic_getattr, __pyx_t_8) < 0) __PYX_ERR(0, 6939, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__260 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__506, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_generic_getattr, 6939, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__260)) __PYX_ERR(0, 6939, __pyx_L1_error)
6940: """
6941: A generic attribute accessor for any class instance.
6942:
6943: This function attempts to retrieve an attribute from the given object.
6944: If the attribute is not found, it provides a meaningful error message.
6945:
6946: Parameters:
6947: ----------
6948: obj : object
6949: The object from which to retrieve the attribute.
6950:
6951: name : str
6952: The name of the attribute to retrieve.
6953:
6954: default_value : any, optional
6955: A default value to return if the attribute is not found. If None,
6956: an AttributeError will be raised.
6957:
6958: Returns:
6959: -------
6960: any
6961: The value of the retrieved attribute or the default value.
6962:
6963: Raises:
6964: ------
6965: AttributeError
6966: If the attribute is not found and no default value is provided.
6967:
6968: Examples:
6969: --------
6970: >>> from gofast.tools.coreutils import generic_getattr
6971: >>> class MyClass:
6972: >>> def __init__(self, a, b):
6973: >>> self.a = a
6974: >>> self.b = b
6975: >>> obj = MyClass(1, 2)
6976: >>> print(generic_getattr(obj, 'a')) # Prints: 1
6977: >>> print(generic_getattr(obj, 'c', 'default')) # Prints: 'default'
6978: """
+6979: if hasattr(obj, name):
__Pyx_TraceLine(6979,0,__PYX_ERR(0, 6979, __pyx_L1_error)) __pyx_t_1 = __Pyx_HasAttr(__pyx_v_obj, __pyx_v_name); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 6979, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+6980: return getattr(obj, name)
__Pyx_TraceLine(6980,0,__PYX_ERR(0, 6980, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetAttr(__pyx_v_obj, __pyx_v_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6980, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
6981:
+6982: if default_value is not None:
__Pyx_TraceLine(6982,0,__PYX_ERR(0, 6982, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_default_value != Py_None); if (__pyx_t_1) { /* … */ }
+6983: return default_value
__Pyx_TraceLine(6983,0,__PYX_ERR(0, 6983, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_default_value); __pyx_r = __pyx_v_default_value; goto __pyx_L0;
6984:
6985: # Attempt to find a similar attribute name for a more informative error
+6986: similar_attr = _find_similar_attribute(obj, name)
__Pyx_TraceLine(6986,0,__PYX_ERR(0, 6986, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_find_similar_attribute); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6986, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_obj, __pyx_v_name}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6986, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_v_similar_attr = __pyx_t_2; __pyx_t_2 = 0;
+6987: suggestion = f". Did you mean '{similar_attr}'?" if similar_attr else ""
__Pyx_TraceLine(6987,0,__PYX_ERR(0, 6987, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_similar_attr); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 6987, __pyx_L1_error) if (__pyx_t_1) { __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6987, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u_Did_you_mean); __pyx_t_6 += 16; __Pyx_GIVEREF(__pyx_kp_u_Did_you_mean); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Did_you_mean); __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_similar_attr, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6987, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__261); __pyx_t_6 += 2; __Pyx_GIVEREF(__pyx_kp_u__261); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u__261); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6987, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_4; __pyx_t_4 = 0; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_2 = __pyx_kp_u__22; } __pyx_v_suggestion = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
6988:
+6989: raise AttributeError(f"'{obj.__class__.__name__}' object has no "
__Pyx_TraceLine(6989,0,__PYX_ERR(0, 6989, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = 0; __pyx_t_7 = 127; __Pyx_INCREF(__pyx_kp_u__262); __pyx_t_6 += 1; __Pyx_GIVEREF(__pyx_kp_u__262); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u__262); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_class); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_object_has_no_attribute); __pyx_t_6 += 27; __Pyx_GIVEREF(__pyx_kp_u_object_has_no_attribute); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u_object_has_no_attribute); /* … */ __Pyx_TraceLine(6989,0,__PYX_ERR(0, 6989, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_2, 6, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_AttributeError, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6989, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 6989, __pyx_L1_error)
+6990: f"attribute '{name}'{suggestion}")
__Pyx_TraceLine(6990,0,__PYX_ERR(0, 6990, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_name, __pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u__262); __pyx_t_6 += 1; __Pyx_GIVEREF(__pyx_kp_u__262); PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_kp_u__262); __pyx_t_4 = __Pyx_PyUnicode_Unicode(__pyx_v_suggestion); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6990, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_7 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_7) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_7; __pyx_t_6 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_2, 5, __pyx_t_4); __pyx_t_4 = 0;
6991:
+6992: def _find_similar_attribute(obj, name):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_216_find_similar_attribute(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_215_find_similar_attribute, "\n Attempts to find a similar attribute name in the object's dictionary.\n\n Parameters\n ----------\n obj : object\n The object whose attributes are being checked.\n name : str\n The name of the attribute to find a similar match for.\n\n Returns\n -------\n str or None\n A similar attribute name if found, otherwise None.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_216_find_similar_attribute = {"_find_similar_attribute", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_216_find_similar_attribute, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_215_find_similar_attribute}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_216_find_similar_attribute(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj = 0; PyObject *__pyx_v_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_find_similar_attribute (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj,&__pyx_n_s_name_2,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6992, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_name_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 6992, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_find_similar_attribute", 1, 2, 2, 1); __PYX_ERR(0, 6992, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_find_similar_attribute") < 0)) __PYX_ERR(0, 6992, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_obj = values[0]; __pyx_v_name = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_find_similar_attribute", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 6992, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._find_similar_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_215_find_similar_attribute(__pyx_self, __pyx_v_obj, __pyx_v_name); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_215_find_similar_attribute(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj, PyObject *__pyx_v_name) { PyObject *__pyx_v_rv = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__263) __Pyx_TraceCall("_find_similar_attribute", __pyx_f[0], 6992, 0, __PYX_ERR(0, 6992, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils._find_similar_attribute", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_rv); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__507 = PyTuple_Pack(3, __pyx_n_s_obj, __pyx_n_s_name_2, __pyx_n_s_rv); if (unlikely(!__pyx_tuple__507)) __PYX_ERR(0, 6992, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__507); __Pyx_GIVEREF(__pyx_tuple__507); /* … */ __Pyx_TraceLine(6992,0,__PYX_ERR(0, 6992, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_216_find_similar_attribute, 0, __pyx_n_s_find_similar_attribute, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__263)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6992, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_find_similar_attribute, __pyx_t_8) < 0) __PYX_ERR(0, 6992, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__263 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__507, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_find_similar_attribute, 6992, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__263)) __PYX_ERR(0, 6992, __pyx_L1_error)
6993: """
6994: Attempts to find a similar attribute name in the object's dictionary.
6995:
6996: Parameters
6997: ----------
6998: obj : object
6999: The object whose attributes are being checked.
7000: name : str
7001: The name of the attribute to find a similar match for.
7002:
7003: Returns
7004: -------
7005: str or None
7006: A similar attribute name if found, otherwise None.
7007: """
+7008: rv = smart_strobj_recognition(name, obj.__dict__, deep =True)
__Pyx_TraceLine(7008,0,__PYX_ERR(0, 7008, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_smart_strobj_recognition); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_name); __Pyx_GIVEREF(__pyx_v_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_name)) __PYX_ERR(0, 7008, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2)) __PYX_ERR(0, 7008, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_deep, Py_True) < 0) __PYX_ERR(0, 7008, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7008, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_rv = __pyx_t_4; __pyx_t_4 = 0;
+7009: return rv
__Pyx_TraceLine(7009,0,__PYX_ERR(0, 7009, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_rv); __pyx_r = __pyx_v_rv; goto __pyx_L0;
7010:
7011:
+7012: def validate_url(url: str) -> bool:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_218validate_url(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_217validate_url, "\n Check if the provided string is a valid URL.\n\n Parameters\n ----------\n url : str\n The string to be checked as a URL.\n\n Raises\n ------\n ValueError\n If the provided string is not a valid URL.\n\n Returns\n -------\n bool\n True if the URL is valid, False otherwise.\n\n Examples\n --------\n >>> validate_url(\"https://www.example.com\")\n True\n >>> validate_url(\"not_a_url\")\n ValueError: The provided string is not a valid URL.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_218validate_url = {"validate_url", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_218validate_url, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_217validate_url}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_218validate_url(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_url = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("validate_url (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_url,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_url)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7012, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "validate_url") < 0)) __PYX_ERR(0, 7012, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_url = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("validate_url", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7012, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.validate_url", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyUnicode_Type), 0, "url", 1))) __PYX_ERR(0, 7012, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_217validate_url(__pyx_self, __pyx_v_url); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_217validate_url(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { PyObject *__pyx_v_urlparse = NULL; PyObject *__pyx_v_parsed_url = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__264) __Pyx_TraceCall("validate_url", __pyx_f[0], 7012, 0, __PYX_ERR(0, 7012, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.validate_url", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_urlparse); __Pyx_XDECREF(__pyx_v_parsed_url); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__508 = PyTuple_Pack(3, __pyx_n_s_url, __pyx_n_s_urlparse, __pyx_n_s_parsed_url); if (unlikely(!__pyx_tuple__508)) __PYX_ERR(0, 7012, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__508); __Pyx_GIVEREF(__pyx_tuple__508); /* … */ __Pyx_TraceLine(7012,0,__PYX_ERR(0, 7012, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_url, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7012, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7012, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_218validate_url, 0, __pyx_n_s_validate_url, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__264)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7012, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_url, __pyx_t_5) < 0) __PYX_ERR(0, 7012, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__264 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__508, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_url, 7012, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__264)) __PYX_ERR(0, 7012, __pyx_L1_error)
7013: """
7014: Check if the provided string is a valid URL.
7015:
7016: Parameters
7017: ----------
7018: url : str
7019: The string to be checked as a URL.
7020:
7021: Raises
7022: ------
7023: ValueError
7024: If the provided string is not a valid URL.
7025:
7026: Returns
7027: -------
7028: bool
7029: True if the URL is valid, False otherwise.
7030:
7031: Examples
7032: --------
7033: >>> validate_url("https://www.example.com")
7034: True
7035: >>> validate_url("not_a_url")
7036: ValueError: The provided string is not a valid URL.
7037: """
+7038: from urllib.parse import urlparse
__Pyx_TraceLine(7038,0,__PYX_ERR(0, 7038, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_urlparse); __Pyx_GIVEREF(__pyx_n_s_urlparse); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_urlparse)) __PYX_ERR(0, 7038, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_urllib_parse, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_urlparse); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7038, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v_urlparse = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7039:
+7040: if is_module_installed("validators"):
__Pyx_TraceLine(7040,0,__PYX_ERR(0, 7040, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_module_installed); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_n_u_validators}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7040, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7040, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_5) { /* … */ }
+7041: return validate_url_by_validators (url)
__Pyx_TraceLine(7041,0,__PYX_ERR(0, 7041, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_validate_url_by_validators); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7041, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_url}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7041, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+7042: parsed_url = urlparse(url)
__Pyx_TraceLine(7042,0,__PYX_ERR(0, 7042, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_urlparse); __pyx_t_1 = __pyx_v_urlparse; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_url}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7042, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_parsed_url = __pyx_t_2; __pyx_t_2 = 0;
+7043: if not parsed_url.scheme or not parsed_url.netloc:
__Pyx_TraceLine(7043,0,__PYX_ERR(0, 7043, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_parsed_url, __pyx_n_s_scheme); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7043, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 7043, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_7 = (!__pyx_t_6); if (!__pyx_t_7) { } else { __pyx_t_5 = __pyx_t_7; goto __pyx_L5_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_parsed_url, __pyx_n_s_netloc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7043, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7043, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (!__pyx_t_7); __pyx_t_5 = __pyx_t_6; __pyx_L5_bool_binop_done:; if (unlikely(__pyx_t_5)) { /* … */ }
+7044: raise ValueError("The provided string is not a valid URL.")
__Pyx_TraceLine(7044,0,__PYX_ERR(0, 7044, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__265, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7044, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 7044, __pyx_L1_error) /* … */ __pyx_tuple__265 = PyTuple_Pack(1, __pyx_kp_u_The_provided_string_is_not_a_val); if (unlikely(!__pyx_tuple__265)) __PYX_ERR(0, 7044, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__265); __Pyx_GIVEREF(__pyx_tuple__265);
+7045: return True
__Pyx_TraceLine(7045,0,__PYX_ERR(0, 7045, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
7046:
+7047: def validate_url_by_validators(url: str):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_220validate_url_by_validators(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_219validate_url_by_validators, "\n Check if the provided string is a valid URL using `validators` packages.\n\n Parameters\n ----------\n url : str\n The string to be checked as a URL.\n\n Raises\n ------\n ValueError\n If the provided string is not a valid URL.\n\n Returns\n -------\n bool\n True if the URL is valid, False otherwise.\n\n Examples\n --------\n >>> validate_url(\"https://www.example.com\")\n True\n >>> validate_url(\"not_a_url\")\n ValueError: The provided string is not a valid URL.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_220validate_url_by_validators = {"validate_url_by_validators", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_220validate_url_by_validators, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_219validate_url_by_validators}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_220validate_url_by_validators(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_url = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("validate_url_by_validators (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_url,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_url)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7047, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "validate_url_by_validators") < 0)) __PYX_ERR(0, 7047, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_url = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("validate_url_by_validators", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7047, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.validate_url_by_validators", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyUnicode_Type), 0, "url", 1))) __PYX_ERR(0, 7047, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_219validate_url_by_validators(__pyx_self, __pyx_v_url); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_219validate_url_by_validators(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { PyObject *__pyx_v_validators = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__266) __Pyx_TraceCall("validate_url_by_validators", __pyx_f[0], 7047, 0, __PYX_ERR(0, 7047, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.validate_url_by_validators", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_validators); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__509 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_validators); if (unlikely(!__pyx_tuple__509)) __PYX_ERR(0, 7047, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__509); __Pyx_GIVEREF(__pyx_tuple__509); /* … */ __Pyx_TraceLine(7047,0,__PYX_ERR(0, 7047, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_url, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7047, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_220validate_url_by_validators, 0, __pyx_n_s_validate_url_by_validators, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__266)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_url_by_validators, __pyx_t_8) < 0) __PYX_ERR(0, 7047, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__266 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__509, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_url_by_validators, 7047, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__266)) __PYX_ERR(0, 7047, __pyx_L1_error)
7048: """
7049: Check if the provided string is a valid URL using `validators` packages.
7050:
7051: Parameters
7052: ----------
7053: url : str
7054: The string to be checked as a URL.
7055:
7056: Raises
7057: ------
7058: ValueError
7059: If the provided string is not a valid URL.
7060:
7061: Returns
7062: -------
7063: bool
7064: True if the URL is valid, False otherwise.
7065:
7066: Examples
7067: --------
7068: >>> validate_url("https://www.example.com")
7069: True
7070: >>> validate_url("not_a_url")
7071: ValueError: The provided string is not a valid URL.
7072: """
+7073: import validators
__Pyx_TraceLine(7073,0,__PYX_ERR(0, 7073, __pyx_L1_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_validators, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_validators = __pyx_t_1; __pyx_t_1 = 0;
+7074: if not validators.url(url):
__Pyx_TraceLine(7074,0,__PYX_ERR(0, 7074, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_validators, __pyx_n_s_url); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_url}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7074, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_6 = (!__pyx_t_5); if (unlikely(__pyx_t_6)) { /* … */ }
+7075: raise ValueError("The provided string is not a valid URL.")
__Pyx_TraceLine(7075,0,__PYX_ERR(0, 7075, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__265, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7075, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7075, __pyx_L1_error)
+7076: return True
__Pyx_TraceLine(7076,0,__PYX_ERR(0, 7076, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
7077:
+7078: def is_module_installed(module_name: str, distribution_name: str = None) -> bool:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_222is_module_installed(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_221is_module_installed, "\n Check if a Python module is installed by attempting to import it.\n Optionally, a distribution name can be provided if it differs from the module name.\n\n Parameters\n ----------\n module_name : str\n The import name of the module to check.\n distribution_name : str, optional\n The distribution name of the package as known by package managers (e.g., pip).\n If provided and the module import fails, an additional check based on the\n distribution name is performed. This parameter is useful for packages where\n the distribution name differs from the importable module name.\n\n Returns\n -------\n bool\n True if the module can be imported or the distribution package is installed,\n False otherwise.\n\n Examples\n --------\n >>> is_module_installed(\"sklearn\")\n True\n >>> is_module_installed(\"scikit-learn\", \"scikit-learn\")\n True\n >>> is_module_installed(\"some_nonexistent_module\")\n False\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_222is_module_installed = {"is_module_installed", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_222is_module_installed, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_221is_module_installed}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_222is_module_installed(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_module_name = 0; PyObject *__pyx_v_distribution_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_module_installed (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_module_name,&__pyx_n_s_distribution_name,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_module_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7078, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_distribution_name); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7078, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "is_module_installed") < 0)) __PYX_ERR(0, 7078, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_module_name = ((PyObject*)values[0]); __pyx_v_distribution_name = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("is_module_installed", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 7078, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.is_module_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_module_name), (&PyUnicode_Type), 0, "module_name", 1))) __PYX_ERR(0, 7078, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distribution_name), (&PyUnicode_Type), 1, "distribution_name", 1))) __PYX_ERR(0, 7078, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_221is_module_installed(__pyx_self, __pyx_v_module_name, __pyx_v_distribution_name); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_221is_module_installed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_module_name, PyObject *__pyx_v_distribution_name) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__267) __Pyx_TraceCall("is_module_installed", __pyx_f[0], 7078, 0, __PYX_ERR(0, 7078, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.is_module_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__510 = PyTuple_Pack(2, __pyx_n_s_module_name, __pyx_n_s_distribution_name); if (unlikely(!__pyx_tuple__510)) __PYX_ERR(0, 7078, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__510); __Pyx_GIVEREF(__pyx_tuple__510); /* … */ __Pyx_TraceLine(7078,0,__PYX_ERR(0, 7078, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7078, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_module_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7078, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_distribution_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7078, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7078, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_222is_module_installed, 0, __pyx_n_s_is_module_installed, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__267)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7078, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__62); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_module_installed, __pyx_t_5) < 0) __PYX_ERR(0, 7078, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__267 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__510, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_module_installed, 7078, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__267)) __PYX_ERR(0, 7078, __pyx_L1_error)
7079: """
7080: Check if a Python module is installed by attempting to import it.
7081: Optionally, a distribution name can be provided if it differs from the module name.
7082:
7083: Parameters
7084: ----------
7085: module_name : str
7086: The import name of the module to check.
7087: distribution_name : str, optional
7088: The distribution name of the package as known by package managers (e.g., pip).
7089: If provided and the module import fails, an additional check based on the
7090: distribution name is performed. This parameter is useful for packages where
7091: the distribution name differs from the importable module name.
7092:
7093: Returns
7094: -------
7095: bool
7096: True if the module can be imported or the distribution package is installed,
7097: False otherwise.
7098:
7099: Examples
7100: --------
7101: >>> is_module_installed("sklearn")
7102: True
7103: >>> is_module_installed("scikit-learn", "scikit-learn")
7104: True
7105: >>> is_module_installed("some_nonexistent_module")
7106: False
7107: """
+7108: if _try_import_module(module_name):
__Pyx_TraceLine(7108,0,__PYX_ERR(0, 7108, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_try_import_module); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_module_name}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7108, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { /* … */ }
+7109: return True
__Pyx_TraceLine(7109,0,__PYX_ERR(0, 7109, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
+7110: if distribution_name and _check_distribution_installed(distribution_name):
__Pyx_TraceLine(7110,0,__PYX_ERR(0, 7110, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_distribution_name != Py_None)&&(__Pyx_PyUnicode_IS_TRUE(__pyx_v_distribution_name) != 0); if (__pyx_t_6) { } else { __pyx_t_5 = __pyx_t_6; goto __pyx_L5_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_check_distribution_installed); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_distribution_name}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 7110, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_6; __pyx_L5_bool_binop_done:; if (__pyx_t_5) { /* … */ }
+7111: return True
__Pyx_TraceLine(7111,0,__PYX_ERR(0, 7111, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
+7112: return False
__Pyx_TraceLine(7112,0,__PYX_ERR(0, 7112, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
7113:
+7114: def _try_import_module(module_name: str) -> bool:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_224_try_import_module(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_223_try_import_module, "\n Attempt to import a module by its name.\n\n Parameters\n ----------\n module_name : str\n The import name of the module.\n\n Returns\n -------\n bool\n True if the module can be imported, False otherwise.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_224_try_import_module = {"_try_import_module", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_224_try_import_module, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_223_try_import_module}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_224_try_import_module(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_module_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_try_import_module (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_module_name,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_module_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7114, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_try_import_module") < 0)) __PYX_ERR(0, 7114, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_module_name = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_try_import_module", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7114, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._try_import_module", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_module_name), (&PyUnicode_Type), 0, "module_name", 1))) __PYX_ERR(0, 7114, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_223_try_import_module(__pyx_self, __pyx_v_module_name); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_223_try_import_module(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_module_name) { PyObject *__pyx_v_importlib = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__268) __Pyx_TraceCall("_try_import_module", __pyx_f[0], 7114, 0, __PYX_ERR(0, 7114, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils._try_import_module", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_importlib); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__511 = PyTuple_Pack(2, __pyx_n_s_module_name, __pyx_n_s_importlib); if (unlikely(!__pyx_tuple__511)) __PYX_ERR(0, 7114, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__511); __Pyx_GIVEREF(__pyx_tuple__511); /* … */ __Pyx_TraceLine(7114,0,__PYX_ERR(0, 7114, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_module_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7114, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7114, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_224_try_import_module, 0, __pyx_n_s_try_import_module, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__268)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7114, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_try_import_module, __pyx_t_8) < 0) __PYX_ERR(0, 7114, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__268 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__511, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_try_import_module, 7114, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__268)) __PYX_ERR(0, 7114, __pyx_L1_error)
7115: """
7116: Attempt to import a module by its name.
7117:
7118: Parameters
7119: ----------
7120: module_name : str
7121: The import name of the module.
7122:
7123: Returns
7124: -------
7125: bool
7126: True if the module can be imported, False otherwise.
7127: """
7128: # import importlib.util
7129: # module_spec = importlib.util.find_spec(module_name)
7130: # return module_spec is not None
+7131: import importlib
__Pyx_TraceLine(7131,0,__PYX_ERR(0, 7131, __pyx_L1_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_importlib, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_importlib = __pyx_t_1; __pyx_t_1 = 0;
+7132: try:
__Pyx_TraceLine(7132,0,__PYX_ERR(0, 7132, __pyx_L1_error)) { /*try:*/ { /* … */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L0; }
+7133: importlib.import_module(module_name)
__Pyx_TraceLine(7133,0,__PYX_ERR(0, 7133, __pyx_L3_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_importlib, __pyx_n_s_import_module); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7133, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_module_name}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7133, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+7134: return True
__Pyx_TraceLine(7134,0,__PYX_ERR(0, 7134, __pyx_L3_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L7_try_return;
+7135: except ImportError:
__Pyx_TraceLine(7135,0,__PYX_ERR(0, 7135, __pyx_L5_except_error)) __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils._try_import_module", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 7135, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_1); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6);
+7136: return False
__Pyx_TraceLine(7136,0,__PYX_ERR(0, 7136, __pyx_L5_except_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; } goto __pyx_L5_except_error;
7137:
+7138: def _check_distribution_installed(distribution_name: str) -> bool:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_226_check_distribution_installed(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_225_check_distribution_installed, "\n Check if a distribution package is installed by its name.\n\n Parameters\n ----------\n distribution_name : str\n The distribution name of the package.\n\n Returns\n -------\n bool\n True if the distribution package is installed, False otherwise.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_226_check_distribution_installed = {"_check_distribution_installed", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_226_check_distribution_installed, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_225_check_distribution_installed}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_226_check_distribution_installed(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_distribution_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_check_distribution_installed (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_distribution_name,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_distribution_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7138, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_check_distribution_installed") < 0)) __PYX_ERR(0, 7138, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_distribution_name = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_check_distribution_installed", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7138, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._check_distribution_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_distribution_name), (&PyUnicode_Type), 0, "distribution_name", 1))) __PYX_ERR(0, 7138, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_225_check_distribution_installed(__pyx_self, __pyx_v_distribution_name); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_225_check_distribution_installed(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_distribution_name) { PyObject *__pyx_v_distribution = NULL; PyObject *__pyx_v_get_distribution = NULL; PyObject *__pyx_v_DistributionNotFound = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__269) __Pyx_TraceCall("_check_distribution_installed", __pyx_f[0], 7138, 0, __PYX_ERR(0, 7138, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils._check_distribution_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_distribution); __Pyx_XDECREF(__pyx_v_get_distribution); __Pyx_XDECREF(__pyx_v_DistributionNotFound); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__512 = PyTuple_Pack(4, __pyx_n_s_distribution_name, __pyx_n_s_distribution, __pyx_n_s_get_distribution, __pyx_n_s_DistributionNotFound); if (unlikely(!__pyx_tuple__512)) __PYX_ERR(0, 7138, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__512); __Pyx_GIVEREF(__pyx_tuple__512); /* … */ __Pyx_TraceLine(7138,0,__PYX_ERR(0, 7138, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_distribution_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7138, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7138, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_226_check_distribution_installed, 0, __pyx_n_s_check_distribution_installed, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__269)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_distribution_installed, __pyx_t_5) < 0) __PYX_ERR(0, 7138, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__269 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__512, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_check_distribution_installed, 7138, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__269)) __PYX_ERR(0, 7138, __pyx_L1_error)
7139: """
7140: Check if a distribution package is installed by its name.
7141:
7142: Parameters
7143: ----------
7144: distribution_name : str
7145: The distribution name of the package.
7146:
7147: Returns
7148: -------
7149: bool
7150: True if the distribution package is installed, False otherwise.
7151: """
+7152: try:
__Pyx_TraceLine(7152,0,__PYX_ERR(0, 7152, __pyx_L1_error)) { /*try:*/ { /* … */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; }
7153: # Prefer importlib.metadata for Python 3.8 and newer
+7154: from importlib.metadata import distribution
__Pyx_TraceLine(7154,0,__PYX_ERR(0, 7154, __pyx_L3_error)) __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7154, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_s_distribution); __Pyx_GIVEREF(__pyx_n_s_distribution); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_distribution)) __PYX_ERR(0, 7154, __pyx_L3_error); __pyx_t_5 = __Pyx_Import(__pyx_n_s_importlib_metadata, __pyx_t_4, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7154, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_distribution); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7154, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_4); __pyx_v_distribution = __pyx_t_4; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+7155: distribution(distribution_name)
__Pyx_TraceLine(7155,0,__PYX_ERR(0, 7155, __pyx_L3_error)) __Pyx_INCREF(__pyx_v_distribution); __pyx_t_4 = __pyx_v_distribution; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_distribution_name}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7155, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+7156: return True
__Pyx_TraceLine(7156,0,__PYX_ERR(0, 7156, __pyx_L3_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L7_try_return;
+7157: except ImportError:
__Pyx_TraceLine(7157,0,__PYX_ERR(0, 7157, __pyx_L5_except_error)) __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils._check_distribution_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_6) < 0) __PYX_ERR(0, 7157, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6);
7158: # Fallback to pkg_resources for older Python versions
+7159: try:
__Pyx_TraceLine(7159,0,__PYX_ERR(0, 7159, __pyx_L5_except_error)) { /*try:*/ { /* … */ } __pyx_L11_error:; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; /* … */ __pyx_L13_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L5_except_error; __pyx_L15_try_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L6_except_return; __pyx_L14_except_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L6_except_return; } }
+7160: from pkg_resources import get_distribution, DistributionNotFound
__Pyx_TraceLine(7160,0,__PYX_ERR(0, 7160, __pyx_L11_error)) __pyx_t_11 = PyList_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7160, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_n_s_get_distribution); __Pyx_GIVEREF(__pyx_n_s_get_distribution); if (__Pyx_PyList_SET_ITEM(__pyx_t_11, 0, __pyx_n_s_get_distribution)) __PYX_ERR(0, 7160, __pyx_L11_error); __Pyx_INCREF(__pyx_n_s_DistributionNotFound); __Pyx_GIVEREF(__pyx_n_s_DistributionNotFound); if (__Pyx_PyList_SET_ITEM(__pyx_t_11, 1, __pyx_n_s_DistributionNotFound)) __PYX_ERR(0, 7160, __pyx_L11_error); __pyx_t_12 = __Pyx_Import(__pyx_n_s_pkg_resources, __pyx_t_11, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 7160, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_ImportFrom(__pyx_t_12, __pyx_n_s_get_distribution); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7160, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_11); __pyx_v_get_distribution = __pyx_t_11; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_ImportFrom(__pyx_t_12, __pyx_n_s_DistributionNotFound); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7160, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_11); __pyx_v_DistributionNotFound = __pyx_t_11; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+7161: get_distribution(distribution_name)
__Pyx_TraceLine(7161,0,__PYX_ERR(0, 7161, __pyx_L11_error)) __Pyx_INCREF(__pyx_v_get_distribution); __pyx_t_11 = __pyx_v_get_distribution; __pyx_t_13 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_13)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_13); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_v_distribution_name}; __pyx_t_12 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 7161, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+7162: return True
__Pyx_TraceLine(7162,0,__PYX_ERR(0, 7162, __pyx_L11_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L15_try_return;
+7163: except DistributionNotFound:
__Pyx_TraceLine(7163,0,__PYX_ERR(0, 7163, __pyx_L13_except_error)) if (unlikely(!__pyx_v_DistributionNotFound)) { __Pyx_RaiseUnboundLocalError("DistributionNotFound"); __PYX_ERR(0, 7163, __pyx_L13_except_error) } __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_v_DistributionNotFound); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils._check_distribution_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_13) < 0) __PYX_ERR(0, 7163, __pyx_L13_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_13);
+7164: return False
__Pyx_TraceLine(7164,0,__PYX_ERR(0, 7164, __pyx_L13_except_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; goto __pyx_L14_except_return; } goto __pyx_L13_except_error;
+7165: except Exception:
__Pyx_TraceLine(7165,0,__PYX_ERR(0, 7165, __pyx_L5_except_error)) __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils._check_distribution_installed", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 7165, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_5);
+7166: return False
__Pyx_TraceLine(7166,0,__PYX_ERR(0, 7166, __pyx_L5_except_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; } goto __pyx_L5_except_error;
7167:
+7168: def get_installation_name(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_228get_installation_name(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_227get_installation_name, "\n Determines the appropriate name for installing a package, considering potential\n discrepancies between the distribution name and the module import name. Optionally,\n returns a boolean indicating if the distribution name matches the import name.\n\n Parameters\n ----------\n module_name : str\n The import name of the module.\n distribution_name : str, optional\n The distribution name of the package. If None, the function attempts to infer\n the distribution name from the module name.\n return_bool : bool, optional\n If True, returns a boolean indicating whether the distribution name matches\n the module import name. Otherwise, returns the name recommended for installation.\n\n Returns\n -------\n Union[str, bool]\n Depending on `return_bool`, returns either a boolean indicating if the distribution\n name matches the module name, or the name (distribution or module) recommended for\n installation.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_228get_installation_name = {"get_installation_name", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_228get_installation_name, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_227get_installation_name}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_228get_installation_name(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_module_name = 0; PyObject *__pyx_v_distribution_name = 0; PyObject *__pyx_v_return_bool = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_installation_name (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_module_name,&__pyx_n_s_distribution_name,&__pyx_n_s_return_bool,0}; PyObject* values[3] = {0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_227get_installation_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_module_name, PyObject *__pyx_v_distribution_name, PyObject *__pyx_v_return_bool) { PyObject *__pyx_v_inferred_name = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__270) __Pyx_TraceCall("get_installation_name", __pyx_f[0], 7168, 0, __PYX_ERR(0, 7168, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.get_installation_name", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_inferred_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__513 = PyTuple_Pack(4, __pyx_n_s_module_name, __pyx_n_s_distribution_name, __pyx_n_s_return_bool, __pyx_n_s_inferred_name); if (unlikely(!__pyx_tuple__513)) __PYX_ERR(0, 7168, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__513); __Pyx_GIVEREF(__pyx_tuple__513); /* … */ __Pyx_TraceLine(7168,0,__PYX_ERR(0, 7168, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_module_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7168, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_distribution_name, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 7168, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_bool, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7168, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_Union_str_bool) < 0) __PYX_ERR(0, 7168, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_228get_installation_name, 0, __pyx_n_s_get_installation_name, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__270)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__473); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_installation_name, __pyx_t_8) < 0) __PYX_ERR(0, 7168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__270 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__513, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_installation_name, 7168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__270)) __PYX_ERR(0, 7168, __pyx_L1_error)
+7169: module_name: str, distribution_name: Optional[str] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+7170: return_bool: bool = False) -> Union[str, bool]:
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_module_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7168, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_distribution_name); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7168, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_bool); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7168, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_installation_name") < 0)) __PYX_ERR(0, 7168, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_module_name = ((PyObject*)values[0]); __pyx_v_distribution_name = values[1]; __pyx_v_return_bool = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_installation_name", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 7168, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_installation_name", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_module_name), (&PyUnicode_Type), 0, "module_name", 1))) __PYX_ERR(0, 7169, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_227get_installation_name(__pyx_self, __pyx_v_module_name, __pyx_v_distribution_name, __pyx_v_return_bool);
7171: """
7172: Determines the appropriate name for installing a package, considering potential
7173: discrepancies between the distribution name and the module import name. Optionally,
7174: returns a boolean indicating if the distribution name matches the import name.
7175:
7176: Parameters
7177: ----------
7178: module_name : str
7179: The import name of the module.
7180: distribution_name : str, optional
7181: The distribution name of the package. If None, the function attempts to infer
7182: the distribution name from the module name.
7183: return_bool : bool, optional
7184: If True, returns a boolean indicating whether the distribution name matches
7185: the module import name. Otherwise, returns the name recommended for installation.
7186:
7187: Returns
7188: -------
7189: Union[str, bool]
7190: Depending on `return_bool`, returns either a boolean indicating if the distribution
7191: name matches the module name, or the name (distribution or module) recommended for
7192: installation.
7193: """
+7194: inferred_name = _infer_distribution_name(module_name)
__Pyx_TraceLine(7194,0,__PYX_ERR(0, 7194, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_infer_distribution_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_module_name}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_inferred_name = __pyx_t_1; __pyx_t_1 = 0;
7195:
7196: # If a distribution name is provided, check if it matches the inferred name
+7197: if distribution_name:
__Pyx_TraceLine(7197,0,__PYX_ERR(0, 7197, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_distribution_name); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7197, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+7198: if return_bool:
__Pyx_TraceLine(7198,0,__PYX_ERR(0, 7198, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_return_bool); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7198, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+7199: return distribution_name.lower() == inferred_name.lower()
__Pyx_TraceLine(7199,0,__PYX_ERR(0, 7199, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution_name, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_inferred_name, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
+7200: return distribution_name
__Pyx_TraceLine(7200,0,__PYX_ERR(0, 7200, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_distribution_name); __pyx_r = __pyx_v_distribution_name; goto __pyx_L0;
7201:
7202: # If no distribution name is provided, return the inferred name or module name
+7203: if return_bool:
__Pyx_TraceLine(7203,0,__PYX_ERR(0, 7203, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_return_bool); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7203, __pyx_L1_error) if (__pyx_t_5) { /* … */ }
+7204: return inferred_name.lower() == module_name.lower()
__Pyx_TraceLine(7204,0,__PYX_ERR(0, 7204, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_inferred_name, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyUnicode_Type_lower, __pyx_v_module_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7204, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7204, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
7205:
+7206: return inferred_name or module_name
__Pyx_TraceLine(7206,0,__PYX_ERR(0, 7206, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_inferred_name); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7206, __pyx_L1_error) if (!__pyx_t_5) { } else { __Pyx_INCREF(__pyx_v_inferred_name); __pyx_t_1 = __pyx_v_inferred_name; goto __pyx_L6_bool_binop_done; } __Pyx_INCREF(__pyx_v_module_name); __pyx_t_1 = __pyx_v_module_name; __pyx_L6_bool_binop_done:; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
7207:
+7208: def _infer_distribution_name(module_name: str) -> str:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_230_infer_distribution_name(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_229_infer_distribution_name, "\n Attempts to infer the distribution name of a package from its module name\n by querying the metadata of installed packages.\n\n Parameters\n ----------\n module_name : str\n The import name of the module.\n\n Returns\n -------\n str\n The inferred distribution name. If no specific inference is made, returns\n the module name.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_230_infer_distribution_name = {"_infer_distribution_name", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_230_infer_distribution_name, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_229_infer_distribution_name}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_230_infer_distribution_name(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_module_name = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_infer_distribution_name (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_module_name,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_module_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7208, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_infer_distribution_name") < 0)) __PYX_ERR(0, 7208, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_module_name = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_infer_distribution_name", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7208, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._infer_distribution_name", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_module_name), (&PyUnicode_Type), 0, "module_name", 1))) __PYX_ERR(0, 7208, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_229_infer_distribution_name(__pyx_self, __pyx_v_module_name); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_24_infer_distribution_name_2generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_229_infer_distribution_name(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_module_name) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name *__pyx_cur_scope; PyObject *__pyx_v_distributions = NULL; PyObject *__pyx_v_distribution = NULL; PyObject *__pyx_v_top_level_txt = NULL; PyObject *__pyx_v_top_level_packages = NULL; PyObject *__pyx_gb_6gofast_5tools_9coreutils_24_infer_distribution_name_2generator11 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__271) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 7208, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("_infer_distribution_name", __pyx_f[0], 7208, 0, __PYX_ERR(0, 7208, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_module_name = __pyx_v_module_name; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_module_name); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_module_name); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils._infer_distribution_name", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_distributions); __Pyx_XDECREF(__pyx_v_distribution); __Pyx_XDECREF(__pyx_v_top_level_txt); __Pyx_XDECREF(__pyx_v_top_level_packages); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_24_infer_distribution_name_2generator11); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__514 = PyTuple_Pack(7, __pyx_n_s_module_name, __pyx_n_s_distributions, __pyx_n_s_distribution, __pyx_n_s_top_level_txt_2, __pyx_n_s_top_level_packages, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__514)) __PYX_ERR(0, 7208, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__514); __Pyx_GIVEREF(__pyx_tuple__514); /* … */ __Pyx_TraceLine(7208,0,__PYX_ERR(0, 7208, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_module_name, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7208, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7208, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_230_infer_distribution_name, 0, __pyx_n_s_infer_distribution_name, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__271)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7208, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_infer_distribution_name, __pyx_t_5) < 0) __PYX_ERR(0, 7208, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__271 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__514, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_infer_distribution_name, 7208, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__271)) __PYX_ERR(0, 7208, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name { PyObject_HEAD PyObject *__pyx_v_module_name; };
7209: """
7210: Attempts to infer the distribution name of a package from its module name
7211: by querying the metadata of installed packages.
7212:
7213: Parameters
7214: ----------
7215: module_name : str
7216: The import name of the module.
7217:
7218: Returns
7219: -------
7220: str
7221: The inferred distribution name. If no specific inference is made, returns
7222: the module name.
7223: """
+7224: try:
__Pyx_TraceLine(7224,0,__PYX_ERR(0, 7224, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); __pyx_L8_try_end:; }
7225: # Use importlib.metadata for Python 3.8+; use importlib_metadata for older versions
+7226: from importlib.metadata import distributions
__Pyx_TraceLine(7226,0,__PYX_ERR(0, 7226, __pyx_L3_error)) __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7226, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_n_s_distributions); __Pyx_GIVEREF(__pyx_n_s_distributions); if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_distributions)) __PYX_ERR(0, 7226, __pyx_L3_error); __pyx_t_5 = __Pyx_Import(__pyx_n_s_importlib_metadata, __pyx_t_4, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7226, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_distributions); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7226, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_4); __pyx_v_distributions = __pyx_t_4; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+7227: except ImportError:
__Pyx_TraceLine(7227,0,__PYX_ERR(0, 7227, __pyx_L5_except_error)) __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError); if (__pyx_t_6) { __Pyx_AddTraceback("gofast.tools.coreutils._infer_distribution_name", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 7227, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_7);
+7228: from importlib_metadata import distributions
__Pyx_TraceLine(7228,0,__PYX_ERR(0, 7228, __pyx_L5_except_error)) __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7228, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_n_s_distributions); __Pyx_GIVEREF(__pyx_n_s_distributions); if (__Pyx_PyList_SET_ITEM(__pyx_t_8, 0, __pyx_n_s_distributions)) __PYX_ERR(0, 7228, __pyx_L5_except_error); __pyx_t_9 = __Pyx_Import(__pyx_n_s_importlib_metadata_2, __pyx_t_8, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7228, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_ImportFrom(__pyx_t_9, __pyx_n_s_distributions); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7228, __pyx_L5_except_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_distributions, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error;
7229: # Loop through all installed distributions
+7230: for distribution in distributions():
__Pyx_TraceLine(7230,0,__PYX_ERR(0, 7230, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_distributions); __pyx_t_4 = __pyx_v_distributions; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_4 = __pyx_t_7; __Pyx_INCREF(__pyx_t_4); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { __pyx_t_10 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7230, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_11)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7230, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 7230, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7230, __pyx_L1_error) #endif if (__pyx_t_10 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_10); __Pyx_INCREF(__pyx_t_7); __pyx_t_10++; if (unlikely((0 < 0))) __PYX_ERR(0, 7230, __pyx_L1_error) #else __pyx_t_7 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7230, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_11(__pyx_t_4); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 7230, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v_distribution, __pyx_t_7); __pyx_t_7 = 0; /* … */ __Pyx_TraceLine(7230,0,__PYX_ERR(0, 7230, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
7231: # Check if the module name matches the distribution name directly
+7232: if module_name == distribution.metadata.get('Name').replace('-', '_'):
__Pyx_TraceLine(7232,0,__PYX_ERR(0, 7232, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_metadata); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_n_u_Name_2}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_replace); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__272, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_module_name, __pyx_t_7, Py_EQ)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_12) { /* … */ } /* … */ __pyx_tuple__272 = PyTuple_Pack(2, __pyx_kp_u__29, __pyx_n_u__8); if (unlikely(!__pyx_tuple__272)) __PYX_ERR(0, 7232, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__272); __Pyx_GIVEREF(__pyx_tuple__272);
+7233: return distribution.metadata['Name']
__Pyx_TraceLine(7233,0,__PYX_ERR(0, 7233, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_metadata); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_Dict_GetItem(__pyx_t_7, __pyx_n_u_Name_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7233, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_9))) __PYX_ERR(0, 7233, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
7234:
7235: # Safely attempt to read and split 'top_level.txt'
+7236: top_level_txt = distribution.read_text('top_level.txt')
__Pyx_TraceLine(7236,0,__PYX_ERR(0, 7236, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_read_text); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_kp_u_top_level_txt}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7236, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_top_level_txt, __pyx_t_9); __pyx_t_9 = 0;
+7237: if top_level_txt:
__Pyx_TraceLine(7237,0,__PYX_ERR(0, 7237, __pyx_L1_error)) __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_top_level_txt); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 7237, __pyx_L1_error) if (__pyx_t_12) { /* … */ }
+7238: top_level_packages = top_level_txt.split()
__Pyx_TraceLine(7238,0,__PYX_ERR(0, 7238, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_top_level_txt, __pyx_n_s_split); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7238, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_XDECREF_SET(__pyx_v_top_level_packages, __pyx_t_9); __pyx_t_9 = 0;
+7239: if any(module_name == pkg.split('.')[0] for pkg in top_level_packages):
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_24_infer_distribution_name_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_29_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_29_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_29_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_29_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_29_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 7239, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name *) __pyx_self;
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_24_infer_distribution_name_2generator11, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_infer_distribution_name_locals, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils._infer_distribution_name.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_24_infer_distribution_name_2generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 7239, __pyx_L1_error)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 7239, __pyx_L1_error) }
if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
__pyx_t_3 = NULL;
} else {
__pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7239, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_3)) {
if (likely(PyList_CheckExact(__pyx_t_1))) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7239, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 7239, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
} else {
{
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7239, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 7239, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
}
} else {
__pyx_t_4 = __pyx_t_3(__pyx_t_1);
if (unlikely(!__pyx_t_4)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(0, 7239, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_4);
}
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pkg);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_pkg, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_module_name)) { __Pyx_RaiseClosureNameError("module_name"); __PYX_ERR(0, 7239, __pyx_L1_error) }
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_pkg, __pyx_n_s_split); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = NULL;
__pyx_t_7 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_5))) {
__pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
if (likely(__pyx_t_6)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
__Pyx_INCREF(__pyx_t_6);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_5, function);
__pyx_t_7 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_kp_u__26};
__pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7);
__Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
}
__pyx_t_5 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_module_name, __pyx_t_5, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
if (__pyx_t_8) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7239,0,__PYX_ERR(0, 7239, __pyx_L1_error))
__pyx_t_9 = __pyx_pf_6gofast_5tools_9coreutils_24_infer_distribution_name_genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_top_level_packages); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_7 = __Pyx_Generator_Next(__pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
__pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 7239, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
if (__pyx_t_12) {
/* … */
}
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_29_genexpr {
PyObject_HEAD
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_28__infer_distribution_name *__pyx_outer_scope;
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_pkg;
};
+7240: return distribution.metadata['Name']
__Pyx_TraceLine(7240,0,__PYX_ERR(0, 7240, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_distribution, __pyx_n_s_metadata); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_Dict_GetItem(__pyx_t_7, __pyx_n_u_Name_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7240, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (!(likely(PyUnicode_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_9))) __PYX_ERR(0, 7240, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L0;
7241:
+7242: return module_name
__Pyx_TraceLine(7242,0,__PYX_ERR(0, 7242, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_module_name); __pyx_r = __pyx_cur_scope->__pyx_v_module_name; goto __pyx_L0;
7243:
+7244: def normalize_string(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_232normalize_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_231normalize_string, "\n Normalizes a string by applying various transformations and optionally checks \n against a list of target strings based on different matching methods.\n\n Function normalizes a string by stripping leading/trailing whitespace, \n converting to lowercase,and optionally checks against a list of target \n strings. If specified, returns the target string that matches the \n conditions. Raise an exception if the string is not found.\n \n Parameters\n ----------\n input_str : str\n The string to be normalized.\n target_strs : List[str], optional\n A list of target strings for comparison.\n num_chars_check : int, optional\n The number of characters at the start of the string to check \n against each target string.\n deep : bool, optional\n If True, performs a deep substring check within each target string.\n return_target_str : bool, optional\n If True and a target string matches, returns the matched target string \n along with the normalized string.\n return_target_only: bool, optional \n If True and a target string matches, returns only the matched string\n target. \n raise_exception : bool, optional\n If True and the input string is not found in the target strings, \n raises an exception.\n ignore_case : bool, optional\n If True, ignores case in string comparisons. Default is True.\n match_method : str, optional\n The string matching method: 'exact', 'contains', or 'startswith'.\n Default is 'exact'.\n error_msg: str, optional, \n Message to raise if `raise_exception` is ``True``. \n \n Returns\n -------\n Union[str, Tuple[str, Optional[str]]]\n The normalized string. If return_target_str is True and a target \n string matches, returns a tuple of the normalized string and the \n matched target string.\n\n Raises\n ------\n ValueError\n If raise_exception is T""rue and the input string is not found in \n the target strings.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import normalize_string\n >>> normalize_string(\"Hello World\", target_strs=[\"hello\", \"world\"], ignore_case=True)\n 'hello world'\n >>> normalize_string(\"Goodbye World\", target_strs=[\"hello\", \"goodbye\"], \n num_chars_check=7, return_target_str=True)\n ('goodbye world', 'goodbye')\n >>> normalize_string(\"Hello Universe\", target_strs=[\"hello\", \"world\"],\n raise_exception=True)\n ValueError: Input string not found in target strings.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_232normalize_string = {"normalize_string", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_232normalize_string, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_231normalize_string}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_232normalize_string(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_input_str = 0; PyObject *__pyx_v_target_strs = 0; PyObject *__pyx_v_num_chars_check = 0; PyObject *__pyx_v_deep = 0; PyObject *__pyx_v_return_target_str = 0; PyObject *__pyx_v_return_target_only = 0; PyObject *__pyx_v_raise_exception = 0; PyObject *__pyx_v_ignore_case = 0; PyObject *__pyx_v_match_method = 0; PyObject *__pyx_v_error_msg = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("normalize_string (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input_str,&__pyx_n_s_target_strs,&__pyx_n_s_num_chars_check,&__pyx_n_s_deep,&__pyx_n_s_return_target_str,&__pyx_n_s_return_target_only,&__pyx_n_s_raise_exception,&__pyx_n_s_ignore_case,&__pyx_n_s_match_method,&__pyx_n_s_error_msg,0}; PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_231normalize_string(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_input_str, PyObject *__pyx_v_target_strs, PyObject *__pyx_v_num_chars_check, PyObject *__pyx_v_deep, PyObject *__pyx_v_return_target_str, PyObject *__pyx_v_return_target_only, PyObject *__pyx_v_raise_exception, PyObject *__pyx_v_ignore_case, PyObject *__pyx_v_match_method, PyObject *__pyx_v_error_msg) { PyObject *__pyx_v_normalized_str = NULL; PyObject *__pyx_v_normalized_targets = NULL; PyObject *__pyx_v_matched_target = NULL; PyObject *__pyx_v_target = NULL; PyObject *__pyx_v_condition = NULL; PyObject *__pyx_9genexpr72__pyx_v_t = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__273) __Pyx_TraceCall("normalize_string", __pyx_f[0], 7244, 0, __PYX_ERR(0, 7244, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_target_strs); __Pyx_INCREF(__pyx_v_error_msg); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.normalize_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_normalized_str); __Pyx_XDECREF(__pyx_v_normalized_targets); __Pyx_XDECREF(__pyx_v_matched_target); __Pyx_XDECREF(__pyx_v_target); __Pyx_XDECREF(__pyx_v_condition); __Pyx_XDECREF(__pyx_9genexpr72__pyx_v_t); __Pyx_XDECREF(__pyx_v_target_strs); __Pyx_XDECREF(__pyx_v_error_msg); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__515 = PyTuple_Pack(16, __pyx_n_s_input_str, __pyx_n_s_target_strs, __pyx_n_s_num_chars_check, __pyx_n_s_deep, __pyx_n_s_return_target_str, __pyx_n_s_return_target_only, __pyx_n_s_raise_exception, __pyx_n_s_ignore_case, __pyx_n_s_match_method, __pyx_n_s_error_msg, __pyx_n_s_normalized_str, __pyx_n_s_normalized_targets, __pyx_n_s_matched_target, __pyx_n_s_target, __pyx_n_s_condition, __pyx_n_s_t); if (unlikely(!__pyx_tuple__515)) __PYX_ERR(0, 7244, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__515); __Pyx_GIVEREF(__pyx_tuple__515); __pyx_codeobj__273 = (PyObject*)__Pyx_PyCode_New(10, 0, 0, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__515, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_normalize_string, 7244, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__273)) __PYX_ERR(0, 7244, __pyx_L1_error) /* … */ __Pyx_TraceLine(7244,0,__PYX_ERR(0, 7244, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_input_str, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_target_strs, __pyx_kp_s_Optional_List_str) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_num_chars_check, __pyx_kp_s_Optional_int) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_deep, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_target_str, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_target_only, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_raise_exception, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_ignore_case, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_match_method, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_error_msg, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_Union_str_Tuple_str_Optional_str) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_232normalize_string, 0, __pyx_n_s_normalize_string, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__273)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7244, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__516); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_normalize_string, __pyx_t_8) < 0) __PYX_ERR(0, 7244, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__516 = PyTuple_Pack(9, Py_None, Py_None, ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_True), ((PyObject*)__pyx_n_u_exact), Py_None); if (unlikely(!__pyx_tuple__516)) __PYX_ERR(0, 7244, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__516); __Pyx_GIVEREF(__pyx_tuple__516);
7245: input_str: str,
+7246: target_strs: Optional[List[str]] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+7247: num_chars_check: Optional[int] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+7248: deep: bool = False,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+7249: return_target_str: bool = False,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+7250: return_target_only: bool=False,
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+7251: raise_exception: bool = False,
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+7252: ignore_case: bool = True,
values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_exact)));
7253: match_method: str = 'exact',
+7254: error_msg: str=None,
values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_input_str)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_target_strs); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_num_chars_check); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_target_str); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_target_only); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_exception); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ignore_case); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_match_method); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_error_msg); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7244, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "normalize_string") < 0)) __PYX_ERR(0, 7244, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_input_str = ((PyObject*)values[0]); __pyx_v_target_strs = values[1]; __pyx_v_num_chars_check = values[2]; __pyx_v_deep = values[3]; __pyx_v_return_target_str = values[4]; __pyx_v_return_target_only = values[5]; __pyx_v_raise_exception = values[6]; __pyx_v_ignore_case = values[7]; __pyx_v_match_method = ((PyObject*)values[8]); __pyx_v_error_msg = ((PyObject*)values[9]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("normalize_string", 0, 1, 10, __pyx_nargs); __PYX_ERR(0, 7244, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.normalize_string", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_input_str), (&PyUnicode_Type), 0, "input_str", 1))) __PYX_ERR(0, 7245, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_match_method), (&PyUnicode_Type), 0, "match_method", 1))) __PYX_ERR(0, 7253, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_error_msg), (&PyUnicode_Type), 1, "error_msg", 1))) __PYX_ERR(0, 7254, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_231normalize_string(__pyx_self, __pyx_v_input_str, __pyx_v_target_strs, __pyx_v_num_chars_check, __pyx_v_deep, __pyx_v_return_target_str, __pyx_v_return_target_only, __pyx_v_raise_exception, __pyx_v_ignore_case, __pyx_v_match_method, __pyx_v_error_msg);
7255: ) -> Union[str, Tuple[str, Optional[str]]]:
7256: """
7257: Normalizes a string by applying various transformations and optionally checks
7258: against a list of target strings based on different matching methods.
7259:
7260: Function normalizes a string by stripping leading/trailing whitespace,
7261: converting to lowercase,and optionally checks against a list of target
7262: strings. If specified, returns the target string that matches the
7263: conditions. Raise an exception if the string is not found.
7264:
7265: Parameters
7266: ----------
7267: input_str : str
7268: The string to be normalized.
7269: target_strs : List[str], optional
7270: A list of target strings for comparison.
7271: num_chars_check : int, optional
7272: The number of characters at the start of the string to check
7273: against each target string.
7274: deep : bool, optional
7275: If True, performs a deep substring check within each target string.
7276: return_target_str : bool, optional
7277: If True and a target string matches, returns the matched target string
7278: along with the normalized string.
7279: return_target_only: bool, optional
7280: If True and a target string matches, returns only the matched string
7281: target.
7282: raise_exception : bool, optional
7283: If True and the input string is not found in the target strings,
7284: raises an exception.
7285: ignore_case : bool, optional
7286: If True, ignores case in string comparisons. Default is True.
7287: match_method : str, optional
7288: The string matching method: 'exact', 'contains', or 'startswith'.
7289: Default is 'exact'.
7290: error_msg: str, optional,
7291: Message to raise if `raise_exception` is ``True``.
7292:
7293: Returns
7294: -------
7295: Union[str, Tuple[str, Optional[str]]]
7296: The normalized string. If return_target_str is True and a target
7297: string matches, returns a tuple of the normalized string and the
7298: matched target string.
7299:
7300: Raises
7301: ------
7302: ValueError
7303: If raise_exception is True and the input string is not found in
7304: the target strings.
7305:
7306: Examples
7307: --------
7308: >>> from gofast.tools.coreutils import normalize_string
7309: >>> normalize_string("Hello World", target_strs=["hello", "world"], ignore_case=True)
7310: 'hello world'
7311: >>> normalize_string("Goodbye World", target_strs=["hello", "goodbye"],
7312: num_chars_check=7, return_target_str=True)
7313: ('goodbye world', 'goodbye')
7314: >>> normalize_string("Hello Universe", target_strs=["hello", "world"],
7315: raise_exception=True)
7316: ValueError: Input string not found in target strings.
7317: """
+7318: normalized_str = str(input_str).lower() if ignore_case else input_str
__Pyx_TraceLine(7318,0,__PYX_ERR(0, 7318, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_case); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7318, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_4 = __Pyx_PyObject_Str(__pyx_v_input_str); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7318, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_input_str); __pyx_t_1 = __pyx_v_input_str; } __pyx_v_normalized_str = __pyx_t_1; __pyx_t_1 = 0;
7319:
+7320: if not target_strs:
__Pyx_TraceLine(7320,0,__PYX_ERR(0, 7320, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_target_strs); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7320, __pyx_L1_error) __pyx_t_7 = (!__pyx_t_2); if (__pyx_t_7) { /* … */ }
+7321: return normalized_str
__Pyx_TraceLine(7321,0,__PYX_ERR(0, 7321, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_normalized_str); __pyx_r = __pyx_v_normalized_str; goto __pyx_L0;
+7322: target_strs = is_iterable(target_strs, exclude_string=True, transform =True)
__Pyx_TraceLine(7322,0,__PYX_ERR(0, 7322, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_target_strs); __Pyx_GIVEREF(__pyx_v_target_strs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_target_strs)) __PYX_ERR(0, 7322, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 7322, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 7322, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7322, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_target_strs, __pyx_t_4); __pyx_t_4 = 0;
+7323: normalized_targets = [str(t).lower() for t in target_strs] if ignore_case else target_strs
__Pyx_TraceLine(7323,0,__PYX_ERR(0, 7323, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_case); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7323, __pyx_L1_error) if (__pyx_t_7) { { /* enter inner scope */ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); if (likely(PyList_CheckExact(__pyx_v_target_strs)) || PyTuple_CheckExact(__pyx_v_target_strs)) { __pyx_t_3 = __pyx_v_target_strs; __Pyx_INCREF(__pyx_t_3); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_target_strs); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7323, __pyx_L6_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7323, __pyx_L6_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 7323, __pyx_L6_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7323, __pyx_L6_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 7323, __pyx_L6_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); #endif } } else { __pyx_t_1 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_1)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 7323, __pyx_L6_error) } break; } __Pyx_GOTREF(__pyx_t_1); } __Pyx_XDECREF_SET(__pyx_9genexpr72__pyx_v_t, __pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = __Pyx_PyObject_Str(__pyx_9genexpr72__pyx_v_t); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_lower); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 7323, __pyx_L6_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr72__pyx_v_t); __pyx_9genexpr72__pyx_v_t = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr72__pyx_v_t); __pyx_9genexpr72__pyx_v_t = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } else { __Pyx_INCREF(__pyx_v_target_strs); __pyx_t_4 = __pyx_v_target_strs; } __pyx_v_normalized_targets = __pyx_t_4; __pyx_t_4 = 0;
+7324: matched_target = None
__Pyx_TraceLine(7324,0,__PYX_ERR(0, 7324, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_matched_target = Py_None;
7325:
+7326: for target in normalized_targets:
__Pyx_TraceLine(7326,0,__PYX_ERR(0, 7326, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_normalized_targets)) || PyTuple_CheckExact(__pyx_v_normalized_targets)) { __pyx_t_4 = __pyx_v_normalized_targets; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_normalized_targets); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7326, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7326, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 7326, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7326, __pyx_L1_error) #endif if (__pyx_t_8 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; if (unlikely((0 < 0))) __PYX_ERR(0, 7326, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7326, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 7326, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_target, __pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(7326,0,__PYX_ERR(0, 7326, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L15_for_end; __pyx_L12_break:; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L15_for_end; __pyx_L15_for_end:;
+7327: if num_chars_check is not None:
__Pyx_TraceLine(7327,0,__PYX_ERR(0, 7327, __pyx_L1_error)) __pyx_t_7 = (__pyx_v_num_chars_check != Py_None); if (__pyx_t_7) { /* … */ goto __pyx_L13; }
+7328: condition = (normalized_str[:num_chars_check] == target[:num_chars_check])
__Pyx_TraceLine(7328,0,__PYX_ERR(0, 7328, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_normalized_str, 0, 0, NULL, &__pyx_v_num_chars_check, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_target, 0, 0, NULL, &__pyx_v_num_chars_check, NULL, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7328, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7328, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_condition, __pyx_t_1); __pyx_t_1 = 0;
+7329: elif deep:
__Pyx_TraceLine(7329,0,__PYX_ERR(0, 7329, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_deep); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7329, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L13; }
+7330: condition = (normalized_str in target)
__Pyx_TraceLine(7330,0,__PYX_ERR(0, 7330, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_normalized_str, __pyx_v_target, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7330, __pyx_L1_error) __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7330, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_condition, __pyx_t_1); __pyx_t_1 = 0;
+7331: elif match_method == 'contains':
__Pyx_TraceLine(7331,0,__PYX_ERR(0, 7331, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_match_method, __pyx_n_u_contains, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7331, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L13; }
+7332: condition = (target in normalized_str)
__Pyx_TraceLine(7332,0,__PYX_ERR(0, 7332, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PySequence_ContainsTF(__pyx_v_target, __pyx_v_normalized_str, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7332, __pyx_L1_error) __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_condition, __pyx_t_1); __pyx_t_1 = 0;
+7333: elif match_method == 'startswith':
__Pyx_TraceLine(7333,0,__PYX_ERR(0, 7333, __pyx_L1_error)) __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_v_match_method, __pyx_n_u_startswith, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7333, __pyx_L1_error) if (__pyx_t_7) { /* … */ goto __pyx_L13; }
+7334: condition = normalized_str.startswith(target)
__Pyx_TraceLine(7334,0,__PYX_ERR(0, 7334, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_normalized_str, __pyx_n_s_startswith); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_target}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_XDECREF_SET(__pyx_v_condition, __pyx_t_1); __pyx_t_1 = 0;
7335: else: # Exact match
+7336: condition = (normalized_str == target)
__Pyx_TraceLine(7336,0,__PYX_ERR(0, 7336, __pyx_L1_error)) /*else*/ { __pyx_t_1 = PyObject_RichCompare(__pyx_v_normalized_str, __pyx_v_target, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7336, __pyx_L1_error) __Pyx_XDECREF_SET(__pyx_v_condition, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L13:;
7337:
+7338: if condition:
__Pyx_TraceLine(7338,0,__PYX_ERR(0, 7338, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_condition); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7338, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+7339: matched_target = target
__Pyx_TraceLine(7339,0,__PYX_ERR(0, 7339, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_target); __Pyx_DECREF_SET(__pyx_v_matched_target, __pyx_v_target);
+7340: break
__Pyx_TraceLine(7340,0,__PYX_ERR(0, 7340, __pyx_L1_error)) goto __pyx_L12_break;
7341:
+7342: if matched_target is not None:
__Pyx_TraceLine(7342,0,__PYX_ERR(0, 7342, __pyx_L1_error)) __pyx_t_7 = (__pyx_v_matched_target != Py_None); if (__pyx_t_7) { /* … */ }
+7343: if return_target_only:
__Pyx_TraceLine(7343,0,__PYX_ERR(0, 7343, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_return_target_only); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7343, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+7344: return matched_target
__Pyx_TraceLine(7344,0,__PYX_ERR(0, 7344, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_matched_target); __pyx_r = __pyx_v_matched_target; goto __pyx_L0;
+7345: return (normalized_str, matched_target) if return_target_str else normalized_str
__Pyx_TraceLine(7345,0,__PYX_ERR(0, 7345, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_return_target_str); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7345, __pyx_L1_error) if (__pyx_t_7) { __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7345, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_normalized_str); __Pyx_GIVEREF(__pyx_v_normalized_str); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_normalized_str)) __PYX_ERR(0, 7345, __pyx_L1_error); __Pyx_INCREF(__pyx_v_matched_target); __Pyx_GIVEREF(__pyx_v_matched_target); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_matched_target)) __PYX_ERR(0, 7345, __pyx_L1_error); __pyx_t_4 = __pyx_t_1; __pyx_t_1 = 0; } else { __Pyx_INCREF(__pyx_v_normalized_str); __pyx_t_4 = __pyx_v_normalized_str; } __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
7346:
+7347: if raise_exception:
__Pyx_TraceLine(7347,0,__PYX_ERR(0, 7347, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_raise_exception); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7347, __pyx_L1_error) if (unlikely(__pyx_t_7)) { /* … */ }
+7348: error_msg = error_msg or (
__Pyx_TraceLine(7348,0,__PYX_ERR(0, 7348, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_error_msg); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7348, __pyx_L1_error) if (!__pyx_t_7) { } else { __Pyx_INCREF(__pyx_v_error_msg); __pyx_t_4 = __pyx_v_error_msg; goto __pyx_L19_bool_binop_done; }
+7349: f"Invalid input. Expect {smart_format(target_strs, 'or')}."
__Pyx_TraceLine(7349,0,__PYX_ERR(0, 7349, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_input_Expect); __pyx_t_8 += 22; __Pyx_GIVEREF(__pyx_kp_u_Invalid_input_Expect); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Invalid_input_Expect); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_v_target_strs, __pyx_n_u_or}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_12; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_Got); __pyx_t_8 += 6; __Pyx_GIVEREF(__pyx_kp_u_Got); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Got); /* … */ __Pyx_TraceLine(7349,0,__PYX_ERR(0, 7349, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 5, __pyx_t_8, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7349, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_INCREF(__pyx_t_5); __pyx_t_4 = __pyx_t_5; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_L19_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_error_msg, ((PyObject*)__pyx_t_4)); __pyx_t_4 = 0;
+7350: f" Got {input_str!r}."
__Pyx_TraceLine(7350,0,__PYX_ERR(0, 7350, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_input_str), __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_12; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u__26);
7351: )
+7352: raise ValueError(error_msg)
__Pyx_TraceLine(7352,0,__PYX_ERR(0, 7352, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_v_error_msg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 7352, __pyx_L1_error)
7353:
+7354: if return_target_only:
__Pyx_TraceLine(7354,0,__PYX_ERR(0, 7354, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_return_target_only); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7354, __pyx_L1_error) if (__pyx_t_7) { /* … */ }
+7355: return matched_target
__Pyx_TraceLine(7355,0,__PYX_ERR(0, 7355, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_matched_target); __pyx_r = __pyx_v_matched_target; goto __pyx_L0;
7356:
+7357: return ('', None) if return_target_str else ''
__Pyx_TraceLine(7357,0,__PYX_ERR(0, 7357, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_return_target_str); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7357, __pyx_L1_error) if (__pyx_t_7) { __Pyx_INCREF(__pyx_tuple__274); __pyx_t_4 = __pyx_tuple__274; } else { __Pyx_INCREF(__pyx_kp_u__22); __pyx_t_4 = __pyx_kp_u__22; } __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0; /* … */ __pyx_tuple__274 = PyTuple_Pack(2, __pyx_kp_u__22, Py_None); if (unlikely(!__pyx_tuple__274)) __PYX_ERR(0, 7357, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__274); __Pyx_GIVEREF(__pyx_tuple__274);
7358:
+7359: def format_and_print_dict(data_dict, front_space=4):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_234format_and_print_dict(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_233format_and_print_dict, "\n Formats and prints the contents of a dictionary in a structured way.\n\n Each key-value pair in the dictionary is printed with the key followed by \n its associated values. \n The values are expected to be dictionaries themselves, allowing for a nested \n representation.\n The inner dictionary's keys are sorted in descending order before printing.\n\n Parameters\n ----------\n data_dict : dict\n A dictionary where each key contains a dictionary of items to be printed. \n The key represents a category\n or label, and the value is another dictionary where each key-value pair \n represents an option or description.\n \n front_space : int, optional\n The number of spaces used for indentation in front of each line (default is 4).\n\n\n Returns\n -------\n None\n This function does not return any value. It prints the formatted contents \n of the provided dictionary.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import format_and_print_dict\n >>> sample_dict = {\n 'gender': {1: 'Male', 0: 'Female'},\n 'age': {1: '35-60', 0: '16-35', 2: '>60'}\n }\n >>> format_and_print_dict(sample_dict)\n gender:\n 1: Male\n 0: Female\n age:\n 2: >60\n 1: 35-60\n 0: 16-35\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_234format_and_print_dict = {"format_and_print_dict", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_234format_and_print_dict, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_233format_and_print_dict}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_234format_and_print_dict(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data_dict = 0; PyObject *__pyx_v_front_space = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("format_and_print_dict (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data_dict,&__pyx_n_s_front_space,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_4))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data_dict)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7359, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_front_space); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7359, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "format_and_print_dict") < 0)) __PYX_ERR(0, 7359, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data_dict = values[0]; __pyx_v_front_space = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("format_and_print_dict", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 7359, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.format_and_print_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_233format_and_print_dict(__pyx_self, __pyx_v_data_dict, __pyx_v_front_space); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_233format_and_print_dict(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data_dict, PyObject *__pyx_v_front_space) { PyObject *__pyx_v_indent = NULL; PyObject *__pyx_v_label = NULL; PyObject *__pyx_v_options = NULL; PyObject *__pyx_v_option = NULL; PyObject *__pyx_v_key = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__275) __Pyx_TraceCall("format_and_print_dict", __pyx_f[0], 7359, 0, __PYX_ERR(0, 7359, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.format_and_print_dict", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_indent); __Pyx_XDECREF(__pyx_v_label); __Pyx_XDECREF(__pyx_v_options); __Pyx_XDECREF(__pyx_v_option); __Pyx_XDECREF(__pyx_v_key); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__517 = PyTuple_Pack(7, __pyx_n_s_data_dict, __pyx_n_s_front_space, __pyx_n_s_indent, __pyx_n_s_label, __pyx_n_s_options, __pyx_n_s_option, __pyx_n_s_key); if (unlikely(!__pyx_tuple__517)) __PYX_ERR(0, 7359, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__517); __Pyx_GIVEREF(__pyx_tuple__517); __pyx_codeobj__275 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__517, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_format_and_print_dict, 7359, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__275)) __PYX_ERR(0, 7359, __pyx_L1_error) /* … */ __Pyx_TraceLine(7359,0,__PYX_ERR(0, 7359, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_234format_and_print_dict, 0, __pyx_n_s_format_and_print_dict, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__275)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7359, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__518); if (PyDict_SetItem(__pyx_d, __pyx_n_s_format_and_print_dict, __pyx_t_8) < 0) __PYX_ERR(0, 7359, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__518 = PyTuple_Pack(1, ((PyObject *)__pyx_int_4)); if (unlikely(!__pyx_tuple__518)) __PYX_ERR(0, 7359, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__518); __Pyx_GIVEREF(__pyx_tuple__518);
7360: """
7361: Formats and prints the contents of a dictionary in a structured way.
7362:
7363: Each key-value pair in the dictionary is printed with the key followed by
7364: its associated values.
7365: The values are expected to be dictionaries themselves, allowing for a nested
7366: representation.
7367: The inner dictionary's keys are sorted in descending order before printing.
7368:
7369: Parameters
7370: ----------
7371: data_dict : dict
7372: A dictionary where each key contains a dictionary of items to be printed.
7373: The key represents a category
7374: or label, and the value is another dictionary where each key-value pair
7375: represents an option or description.
7376:
7377: front_space : int, optional
7378: The number of spaces used for indentation in front of each line (default is 4).
7379:
7380:
7381: Returns
7382: -------
7383: None
7384: This function does not return any value. It prints the formatted contents
7385: of the provided dictionary.
7386:
7387: Examples
7388: --------
7389: >>> from gofast.tools.coreutils import format_and_print_dict
7390: >>> sample_dict = {
7391: 'gender': {1: 'Male', 0: 'Female'},
7392: 'age': {1: '35-60', 0: '16-35', 2: '>60'}
7393: }
7394: >>> format_and_print_dict(sample_dict)
7395: gender:
7396: 1: Male
7397: 0: Female
7398: age:
7399: 2: >60
7400: 1: 35-60
7401: 0: 16-35
7402: """
+7403: if not isinstance(data_dict, dict):
__Pyx_TraceLine(7403,0,__PYX_ERR(0, 7403, __pyx_L1_error)) __pyx_t_1 = PyDict_Check(__pyx_v_data_dict); __pyx_t_2 = (!__pyx_t_1); if (unlikely(__pyx_t_2)) { /* … */ }
+7404: raise TypeError("The input data must be a dictionary.")
__Pyx_TraceLine(7404,0,__PYX_ERR(0, 7404, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__276, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 7404, __pyx_L1_error) /* … */ __pyx_tuple__276 = PyTuple_Pack(1, __pyx_kp_u_The_input_data_must_be_a_diction); if (unlikely(!__pyx_tuple__276)) __PYX_ERR(0, 7404, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__276); __Pyx_GIVEREF(__pyx_tuple__276);
7405:
+7406: indent = ' ' * front_space
__Pyx_TraceLine(7406,0,__PYX_ERR(0, 7406, __pyx_L1_error)) __pyx_t_3 = PyNumber_Multiply(__pyx_kp_u__14, __pyx_v_front_space); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_indent = __pyx_t_3; __pyx_t_3 = 0;
+7407: for label, options in data_dict.items():
__Pyx_TraceLine(7407,0,__PYX_ERR(0, 7407, __pyx_L1_error)) __pyx_t_4 = 0; if (unlikely(__pyx_v_data_dict == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 7407, __pyx_L1_error) } __pyx_t_7 = __Pyx_dict_iterator(__pyx_v_data_dict, 0, __pyx_n_s_items, (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = __pyx_t_7; __pyx_t_7 = 0; while (1) { __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_5, &__pyx_t_4, &__pyx_t_7, &__pyx_t_8, NULL, __pyx_t_6); if (unlikely(__pyx_t_9 == 0)) break; if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 7407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_8); __Pyx_XDECREF_SET(__pyx_v_label, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_options, __pyx_t_8); __pyx_t_8 = 0;
+7408: print(f"{label}:")
__Pyx_TraceLine(7408,0,__PYX_ERR(0, 7408, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_v_label, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_8, __pyx_kp_u__32); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+7409: options= is_iterable(options, exclude_string=True, transform=True )
__Pyx_TraceLine(7409,0,__PYX_ERR(0, 7409, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_options); __Pyx_GIVEREF(__pyx_v_options); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_options)) __PYX_ERR(0, 7409, __pyx_L1_error); __pyx_t_10 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 7409, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 7409, __pyx_L1_error) __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF_SET(__pyx_v_options, __pyx_t_11); __pyx_t_11 = 0;
7410:
+7411: if isinstance(options, (tuple, list)):
__Pyx_TraceLine(7411,0,__PYX_ERR(0, 7411, __pyx_L1_error)) __pyx_t_1 = PyTuple_Check(__pyx_v_options); if (!__pyx_t_1) { } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L7_bool_binop_done; } __pyx_t_1 = PyList_Check(__pyx_v_options); __pyx_t_2 = __pyx_t_1; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ goto __pyx_L6; }
+7412: for option in options:
__Pyx_TraceLine(7412,0,__PYX_ERR(0, 7412, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_options)) || PyTuple_CheckExact(__pyx_v_options)) { __pyx_t_11 = __pyx_v_options; __Pyx_INCREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_v_options); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 7412, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_11))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_11); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7412, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_10 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 7412, __pyx_L1_error) #else __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_11, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_11); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7412, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_12); __Pyx_INCREF(__pyx_t_10); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 7412, __pyx_L1_error) #else __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_11, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); #endif } } else { __pyx_t_10 = __pyx_t_13(__pyx_t_11); if (unlikely(!__pyx_t_10)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 7412, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_10); } __Pyx_XDECREF_SET(__pyx_v_option, __pyx_t_10); __pyx_t_10 = 0; /* … */ __Pyx_TraceLine(7412,0,__PYX_ERR(0, 7412, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+7413: print(f"{indent}{option}")
__Pyx_TraceLine(7413,0,__PYX_ERR(0, 7413, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_v_indent, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_option, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+7414: elif isinstance(options, dict):
__Pyx_TraceLine(7414,0,__PYX_ERR(0, 7414, __pyx_L1_error)) __pyx_t_2 = PyDict_Check(__pyx_v_options); if (__pyx_t_2) { /* … */ } __pyx_L6:;
+7415: for key in sorted(options.keys(), reverse=True):
__Pyx_TraceLine(7415,0,__PYX_ERR(0, 7415, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_options, __pyx_n_s_keys); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_9, 0+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_11); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_11)) __PYX_ERR(0, 7415, __pyx_L1_error); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_reverse, Py_True) < 0) __PYX_ERR(0, 7415, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_sorted, __pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (likely(PyList_CheckExact(__pyx_t_8)) || PyTuple_CheckExact(__pyx_t_8)) { __pyx_t_11 = __pyx_t_8; __Pyx_INCREF(__pyx_t_11); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 7415, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_11))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_11); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7415, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_12); __Pyx_INCREF(__pyx_t_8); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 7415, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_11, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_11); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 7415, __pyx_L1_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_12); __Pyx_INCREF(__pyx_t_8); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 7415, __pyx_L1_error) #else __pyx_t_8 = __Pyx_PySequence_ITEM(__pyx_t_11, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7415, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); #endif } } else { __pyx_t_8 = __pyx_t_13(__pyx_t_11); if (unlikely(!__pyx_t_8)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 7415, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_8); } __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_8); __pyx_t_8 = 0; /* … */ __Pyx_TraceLine(7415,0,__PYX_ERR(0, 7415, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+7416: print(f"{indent}{key}: {options[key]}")
__Pyx_TraceLine(7416,0,__PYX_ERR(0, 7416, __pyx_L1_error)) __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_14 = 0; __pyx_t_15 = 127; __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_indent, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_v_key, __pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u__68); __pyx_t_14 += 2; __Pyx_GIVEREF(__pyx_kp_u__68); PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_kp_u__68); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_options, __pyx_v_key); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_15 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_15) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_15; __pyx_t_14 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_8, 4, __pyx_t_14, __pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7416, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+7417: print() # Adds an empty line for better readability between categories
__Pyx_TraceLine(7417,0,__PYX_ERR(0, 7417, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_builtin_print); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7418:
7419:
+7420: def fill_nan_in(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_236fill_nan_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_235fill_nan_in, "\n Fills NaN values in a Pandas DataFrame using various methods.\n\n Parameters\n ----------\n data : pd.DataFrame\n The DataFrame to be checked and modified.\n method : str, optional\n The method to use for filling NaN values. Options include 'constant',\n 'ffill', 'bfill', 'mean', 'median', 'mode'. Default is 'constant'.\n value : int, float, string, optional\n The value used when method is 'constant'. Ignored for other methods.\n Default is 0.\n\n Returns\n -------\n df : pd.DataFrame\n The DataFrame with NaN values filled.\n\n Example\n -------\n >>> import pandas as pd\n >>> from gofast.tools.coreutils import fill_nan_in\n >>> df = pd.DataFrame({'A': [1, 2, np.nan], 'B': [np.nan, 2, 3]})\n >>> df = fill_nan_in(df, method='median')\n >>> print(df)\n A B\n 0 1.0 2.5\n 1 2.0 2.0\n 2 1.5 3.0\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_236fill_nan_in = {"fill_nan_in", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_236fill_nan_in, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_235fill_nan_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_236fill_nan_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_method = 0; PyObject *__pyx_v_value = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fill_nan_in (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_method,&__pyx_n_s_value,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_constant))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7420, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_method); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7420, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7420, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "fill_nan_in") < 0)) __PYX_ERR(0, 7420, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_method = ((PyObject*)values[1]); __pyx_v_value = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("fill_nan_in", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 7420, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyUnicode_Type), 0, "method", 1))) __PYX_ERR(0, 7421, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_235fill_nan_in(__pyx_self, __pyx_v_data, __pyx_v_method, __pyx_v_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_235fill_nan_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_method, PyObject *__pyx_v_value) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope; PyObject *__pyx_v_fill_methods = NULL; PyObject *__pyx_v_fill_action = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__277) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 7420, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("fill_nan_in", __pyx_f[0], 7420, 0, __PYX_ERR(0, 7420, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_data = __pyx_v_data; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_data); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_data); __pyx_cur_scope->__pyx_v_value = __pyx_v_value; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_value); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_value); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_fill_methods); __Pyx_XDECREF(__pyx_v_fill_action); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__519 = PyTuple_Pack(5, __pyx_n_s_data, __pyx_n_s_method, __pyx_n_s_value, __pyx_n_s_fill_methods, __pyx_n_s_fill_action); if (unlikely(!__pyx_tuple__519)) __PYX_ERR(0, 7420, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__519); __Pyx_GIVEREF(__pyx_tuple__519); __pyx_codeobj__277 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__519, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_fill_nan_in, 7420, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__277)) __PYX_ERR(0, 7420, __pyx_L1_error) /* … */ __Pyx_TraceLine(7420,0,__PYX_ERR(0, 7420, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_data, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 7420, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_method, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7420, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_value, __pyx_kp_s_Optional_Union_int_float_str) < 0) __PYX_ERR(0, 7420, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 7420, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_236fill_nan_in, 0, __pyx_n_s_fill_nan_in, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__277)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__520); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_fill_nan_in, __pyx_t_5) < 0) __PYX_ERR(0, 7420, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__520 = PyTuple_Pack(2, ((PyObject*)__pyx_n_u_constant), ((PyObject *)__pyx_int_0)); if (unlikely(!__pyx_tuple__520)) __PYX_ERR(0, 7420, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__520); __Pyx_GIVEREF(__pyx_tuple__520); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in { PyObject_HEAD PyObject *__pyx_v_data; PyObject *__pyx_v_value; };
7421: data: DataFrame, method: str = 'constant',
7422: value: Optional[Union[int, float, str]] = 0) -> DataFrame:
7423: """
7424: Fills NaN values in a Pandas DataFrame using various methods.
7425:
7426: Parameters
7427: ----------
7428: data : pd.DataFrame
7429: The DataFrame to be checked and modified.
7430: method : str, optional
7431: The method to use for filling NaN values. Options include 'constant',
7432: 'ffill', 'bfill', 'mean', 'median', 'mode'. Default is 'constant'.
7433: value : int, float, string, optional
7434: The value used when method is 'constant'. Ignored for other methods.
7435: Default is 0.
7436:
7437: Returns
7438: -------
7439: df : pd.DataFrame
7440: The DataFrame with NaN values filled.
7441:
7442: Example
7443: -------
7444: >>> import pandas as pd
7445: >>> from gofast.tools.coreutils import fill_nan_in
7446: >>> df = pd.DataFrame({'A': [1, 2, np.nan], 'B': [np.nan, 2, 3]})
7447: >>> df = fill_nan_in(df, method='median')
7448: >>> print(df)
7449: A B
7450: 0 1.0 2.5
7451: 1 2.0 2.0
7452: 2 1.5 3.0
7453: """
7454: # Check for NaN values in the DataFrame and apply the specified fill method
+7455: if not data.isna().any().any():
__Pyx_TraceLine(7455,0,__PYX_ERR(0, 7455, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_isna); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_any); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_any); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 7455, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_8 = (!__pyx_t_7); if (__pyx_t_8) { /* … */ }
+7456: return data
__Pyx_TraceLine(7456,0,__PYX_ERR(0, 7456, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_data); __pyx_r = __pyx_cur_scope->__pyx_v_data; goto __pyx_L0;
7457:
7458: fill_methods = {
+7459: 'constant': lambda: data.fillna(value, inplace=True),
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_lambda26(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_lambda26 = {"lambda26", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_lambda26, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_lambda26(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda26 (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_lambda_funcdef_lambda26(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda26(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda26", __pyx_f[0], 7459, 0, __PYX_ERR(0, 7459, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7459, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_fillna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(!__pyx_cur_scope->__pyx_v_value)) { __Pyx_RaiseClosureNameError("value"); __PYX_ERR(0, 7459, __pyx_L1_error) }
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_value);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_value);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_value)) __PYX_ERR(0, 7459, __pyx_L1_error);
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda26", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7459,0,__PYX_ERR(0, 7459, __pyx_L1_error))
__pyx_t_1 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_lambda26, 0, __pyx_n_s_fill_nan_in_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_constant, __pyx_t_4) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+7460: 'ffill': lambda: data.fillna(method='ffill', inplace=True),
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_1lambda27(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_1lambda27 = {"lambda27", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_1lambda27, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_1lambda27(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda27 (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_lambda_funcdef_lambda27(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda27(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda27", __pyx_f[0], 7460, 0, __PYX_ERR(0, 7460, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7460, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_fillna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7460, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7460, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_method, __pyx_n_u_ffill) < 0) __PYX_ERR(0, 7460, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 7460, __pyx_L1_error)
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7460, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda27", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7460,0,__PYX_ERR(0, 7460, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_1lambda27, 0, __pyx_n_s_fill_nan_in_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7460, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_ffill, __pyx_t_4) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+7461: 'bfill': lambda: data.fillna(method='bfill', inplace=True),
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_2lambda28(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_2lambda28 = {"lambda28", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_2lambda28, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_2lambda28(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda28 (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_lambda_funcdef_lambda28(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda28(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda28", __pyx_f[0], 7461, 0, __PYX_ERR(0, 7461, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7461, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_fillna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7461, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7461, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_method, __pyx_n_u_bfill) < 0) __PYX_ERR(0, 7461, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 7461, __pyx_L1_error)
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7461, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda28", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7461,0,__PYX_ERR(0, 7461, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_2lambda28, 0, __pyx_n_s_fill_nan_in_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7461, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_bfill, __pyx_t_4) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+7462: 'mean': lambda: data.fillna(data.mean(), inplace=True),
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_3lambda29(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_3lambda29 = {"lambda29", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_3lambda29, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_3lambda29(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda29 (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_lambda_funcdef_lambda29(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda29(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda29", __pyx_f[0], 7462, 0, __PYX_ERR(0, 7462, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7462, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_fillna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7462, __pyx_L1_error) }
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_mean); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_2);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 7462, __pyx_L1_error);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 7462, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda29", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7462,0,__PYX_ERR(0, 7462, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_3lambda29, 0, __pyx_n_s_fill_nan_in_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7462, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_mean, __pyx_t_4) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+7463: 'median': lambda: data.fillna(data.median(), inplace=True),
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_4lambda30(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_4lambda30 = {"lambda30", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_4lambda30, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_4lambda30(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda30 (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_lambda_funcdef_lambda30(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda30(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda30", __pyx_f[0], 7463, 0, __PYX_ERR(0, 7463, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7463, __pyx_L1_error) }
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_fillna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7463, __pyx_L1_error) }
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_median); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_GIVEREF(__pyx_t_2);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 7463, __pyx_L1_error);
__pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 7463, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda30", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7463,0,__PYX_ERR(0, 7463, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_4lambda30, 0, __pyx_n_s_fill_nan_in_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7463, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_median, __pyx_t_4) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+7464: 'mode': lambda: data.apply(lambda col: col.fillna(col.mode()[0], inplace=True))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_5lambda31(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_5lambda31 = {"lambda31", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_5lambda31, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_5lambda31(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda31 (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_lambda_funcdef_lambda31(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_8lambda31_lambda32(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_8lambda31_lambda32 = {"lambda32", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_8lambda31_lambda32, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_11fill_nan_in_8lambda31_lambda32(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_col = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda32 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_col,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_col)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7464, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda32") < 0)) __PYX_ERR(0, 7464, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_col = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda32", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7464, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda31.lambda32", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda32(__pyx_self, __pyx_v_col);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda32(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_col) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda32", __pyx_f[0], 7464, 0, __PYX_ERR(0, 7464, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_fillna); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_col, __pyx_n_s_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_3))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_3, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_3);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3)) __PYX_ERR(0, 7464, __pyx_L1_error);
__pyx_t_3 = 0;
__pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 7464, __pyx_L1_error)
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda31.lambda32", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda31(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_30_fill_nan_in *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda31", __pyx_f[0], 7464, 0, __PYX_ERR(0, 7464, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_data)) { __Pyx_RaiseClosureNameError("data"); __PYX_ERR(0, 7464, __pyx_L1_error) }
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_data, __pyx_n_s_apply); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_8lambda31_lambda32, 0, __pyx_n_s_fill_nan_in_locals_lambda_locals, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.fill_nan_in.lambda31", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(7464,0,__PYX_ERR(0, 7464, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_11fill_nan_in_5lambda31, 0, __pyx_n_s_fill_nan_in_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7464, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_mode, __pyx_t_4) < 0) __PYX_ERR(0, 7459, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_v_fill_methods = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
7465: }
7466:
+7467: fill_action = fill_methods.get(method)
__Pyx_TraceLine(7467,0,__PYX_ERR(0, 7467, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_fill_methods, __pyx_v_method, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_fill_action = __pyx_t_1; __pyx_t_1 = 0;
+7468: if fill_action:
__Pyx_TraceLine(7468,0,__PYX_ERR(0, 7468, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_fill_action); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 7468, __pyx_L1_error) if (likely(__pyx_t_8)) { /* … */ goto __pyx_L4; }
+7469: fill_action()
__Pyx_TraceLine(7469,0,__PYX_ERR(0, 7469, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_fill_action); __pyx_t_4 = __pyx_v_fill_action; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7470: else:
+7471: raise ValueError(f"Method '{method}' not recognized for filling NaN values.")
__Pyx_TraceLine(7471,0,__PYX_ERR(0, 7471, __pyx_L1_error)) /*else*/ { __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_9 = 0; __pyx_t_10 = 127; __Pyx_INCREF(__pyx_kp_u_Method); __pyx_t_9 += 8; __Pyx_GIVEREF(__pyx_kp_u_Method); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Method); __Pyx_INCREF(__pyx_v_method); __pyx_t_10 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_method) > __pyx_t_10) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_v_method) : __pyx_t_10; __pyx_t_9 += __Pyx_PyUnicode_GET_LENGTH(__pyx_v_method); __Pyx_GIVEREF(__pyx_v_method); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_method); __Pyx_INCREF(__pyx_kp_u_not_recognized_for_filling_NaN); __pyx_t_9 += 40; __Pyx_GIVEREF(__pyx_kp_u_not_recognized_for_filling_NaN); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_not_recognized_for_filling_NaN); __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7471, __pyx_L1_error) } __pyx_L4:;
7472:
+7473: return data
__Pyx_TraceLine(7473,0,__PYX_ERR(0, 7473, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_data); __pyx_r = __pyx_cur_scope->__pyx_v_data; goto __pyx_L0;
7474:
+7475: def get_valid_kwargs(obj_or_func, raise_warning=False, **kwargs):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_238get_valid_kwargs(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_237get_valid_kwargs, "\n Filters keyword arguments (`kwargs`) to retain only those that are valid\n for the initializer of a given object or function.\n\n Parameters\n ----------\n obj_or_func : object or function\n The object or function to inspect for valid keyword arguments. If it's\n callable, its `__init__` method's valid keyword arguments are considered.\n raise_warning : bool, optional\n If True, raises a warning for any keyword arguments provided that are not\n valid for `obj_or_func`. The default is False.\n **kwargs : dict\n Arbitrary keyword arguments to filter based on `obj_or_func`'s\n valid parameters.\n\n Returns\n -------\n dict\n A dictionary containing only the keyword arguments that are valid for the\n `obj_or_func`'s initializer.\n\n Raises\n ------\n Warning\n If `raise_warning` is True and there are keyword arguments that are not\n valid for `obj_or_func`, a warning is raised.\n\n Notes\n -----\n This function checks whether the provided keyword arguments are valid for the given\n class, method, or function. It filters out any invalid keyword arguments and returns\n a dictionary containing only the valid ones.\n\n If the provided object is a class, it inspects the __init__ method to determine the\n valid keyword arguments. If it is a method or function, it inspects the argument names.\n\n It issues a warning for any invalid keyword arguments if `raise_warning`\n is ``True`` but it does not raise an error.\n \n Examples\n --------\n >>> from gofast.tools.coreutils import get_valid_kwargs\n >>> class MyClass:\n ... def __init__(self, a, b):\n ... self.a = a\n ... self.b = b\n >>> valid_kwargs = get_valid_kwargs(MyClass, a=1, b=2, c=3)\n >>> print(valid_kwargs)\n {'a': 1, 'b': 2}\n >>> valid_kwargs = get_valid_kwargs(MyClass, raise_warning=True, **kwargs)\n Warning: 'arg3' is ""not a valid keyword argument for 'MyClass'.\n >>> print(valid_kwargs)\n {'arg1': 1, 'arg2': 2}\n\n >>> def my_function(a, b, c):\n ... return a + b + c\n ...\n >>> kwargs = {'a': 1, 'b': 2, 'd': 3}\n >>> valid_kwargs = get_valid_kwargs(my_function, raise_warning=True, **kwargs)\n Warning: 'd' is not a valid keyword argument for 'my_function'.\n >>> print(valid_kwargs)\n {'a': 1, 'b': 2}\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_238get_valid_kwargs = {"get_valid_kwargs", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_238get_valid_kwargs, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_237get_valid_kwargs}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_238get_valid_kwargs(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_obj_or_func = 0; PyObject *__pyx_v_raise_warning = 0; PyObject *__pyx_v_kwargs = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_valid_kwargs (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL; __Pyx_GOTREF(__pyx_v_kwargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_obj_or_func,&__pyx_n_s_raise_warning,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_obj_or_func)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7475, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_warning); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7475, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kwargs, values + 0, kwd_pos_args, "get_valid_kwargs") < 0)) __PYX_ERR(0, 7475, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_obj_or_func = values[0]; __pyx_v_raise_warning = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_valid_kwargs", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 7475, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; __Pyx_AddTraceback("gofast.tools.coreutils.get_valid_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_237get_valid_kwargs(__pyx_self, __pyx_v_obj_or_func, __pyx_v_raise_warning, __pyx_v_kwargs); /* function exit code */ __Pyx_DECREF(__pyx_v_kwargs); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_237get_valid_kwargs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_obj_or_func, PyObject *__pyx_v_raise_warning, PyObject *__pyx_v_kwargs) { PyObject *__pyx_v_valid_kwargs = NULL; PyObject *__pyx_v_not_valid_keys = NULL; PyObject *__pyx_v_obj = NULL; PyObject *__pyx_v_valid_args = NULL; PyObject *__pyx_v_key = NULL; PyObject *__pyx_v_value = NULL; PyObject *__pyx_v_warning_msg = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__278) __Pyx_TraceCall("get_valid_kwargs", __pyx_f[0], 7475, 0, __PYX_ERR(0, 7475, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.get_valid_kwargs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_valid_kwargs); __Pyx_XDECREF(__pyx_v_not_valid_keys); __Pyx_XDECREF(__pyx_v_obj); __Pyx_XDECREF(__pyx_v_valid_args); __Pyx_XDECREF(__pyx_v_key); __Pyx_XDECREF(__pyx_v_value); __Pyx_XDECREF(__pyx_v_warning_msg); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__521 = PyTuple_Pack(10, __pyx_n_s_obj_or_func, __pyx_n_s_raise_warning, __pyx_n_s_kwargs, __pyx_n_s_valid_kwargs, __pyx_n_s_not_valid_keys, __pyx_n_s_obj, __pyx_n_s_valid_args, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_warning_msg); if (unlikely(!__pyx_tuple__521)) __PYX_ERR(0, 7475, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__521); __Pyx_GIVEREF(__pyx_tuple__521); /* … */ __Pyx_TraceLine(7475,0,__PYX_ERR(0, 7475, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_238get_valid_kwargs, 0, __pyx_n_s_get_valid_kwargs, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__278)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7475, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__384); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_valid_kwargs, __pyx_t_5) < 0) __PYX_ERR(0, 7475, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__278 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__521, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_valid_kwargs, 7475, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__278)) __PYX_ERR(0, 7475, __pyx_L1_error)
7476: """
7477: Filters keyword arguments (`kwargs`) to retain only those that are valid
7478: for the initializer of a given object or function.
7479:
7480: Parameters
7481: ----------
7482: obj_or_func : object or function
7483: The object or function to inspect for valid keyword arguments. If it's
7484: callable, its `__init__` method's valid keyword arguments are considered.
7485: raise_warning : bool, optional
7486: If True, raises a warning for any keyword arguments provided that are not
7487: valid for `obj_or_func`. The default is False.
7488: **kwargs : dict
7489: Arbitrary keyword arguments to filter based on `obj_or_func`'s
7490: valid parameters.
7491:
7492: Returns
7493: -------
7494: dict
7495: A dictionary containing only the keyword arguments that are valid for the
7496: `obj_or_func`'s initializer.
7497:
7498: Raises
7499: ------
7500: Warning
7501: If `raise_warning` is True and there are keyword arguments that are not
7502: valid for `obj_or_func`, a warning is raised.
7503:
7504: Notes
7505: -----
7506: This function checks whether the provided keyword arguments are valid for the given
7507: class, method, or function. It filters out any invalid keyword arguments and returns
7508: a dictionary containing only the valid ones.
7509:
7510: If the provided object is a class, it inspects the __init__ method to determine the
7511: valid keyword arguments. If it is a method or function, it inspects the argument names.
7512:
7513: It issues a warning for any invalid keyword arguments if `raise_warning`
7514: is ``True`` but it does not raise an error.
7515:
7516: Examples
7517: --------
7518: >>> from gofast.tools.coreutils import get_valid_kwargs
7519: >>> class MyClass:
7520: ... def __init__(self, a, b):
7521: ... self.a = a
7522: ... self.b = b
7523: >>> valid_kwargs = get_valid_kwargs(MyClass, a=1, b=2, c=3)
7524: >>> print(valid_kwargs)
7525: {'a': 1, 'b': 2}
7526: >>> valid_kwargs = get_valid_kwargs(MyClass, raise_warning=True, **kwargs)
7527: Warning: 'arg3' is not a valid keyword argument for 'MyClass'.
7528: >>> print(valid_kwargs)
7529: {'arg1': 1, 'arg2': 2}
7530:
7531: >>> def my_function(a, b, c):
7532: ... return a + b + c
7533: ...
7534: >>> kwargs = {'a': 1, 'b': 2, 'd': 3}
7535: >>> valid_kwargs = get_valid_kwargs(my_function, raise_warning=True, **kwargs)
7536: Warning: 'd' is not a valid keyword argument for 'my_function'.
7537: >>> print(valid_kwargs)
7538: {'a': 1, 'b': 2}
7539: """
+7540: valid_kwargs = {}
__Pyx_TraceLine(7540,0,__PYX_ERR(0, 7540, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7540, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_valid_kwargs = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+7541: not_valid_keys = []
__Pyx_TraceLine(7541,0,__PYX_ERR(0, 7541, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_not_valid_keys = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
7542:
7543: # Determine whether obj_or_func is callable and get its valid arguments
+7544: obj = obj_or_func() if callable(obj_or_func) else obj_or_func
__Pyx_TraceLine(7544,0,__PYX_ERR(0, 7544, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyCallable_Check(__pyx_v_obj_or_func); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 7544, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_v_obj_or_func); __pyx_t_4 = __pyx_v_obj_or_func; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7544, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else { __Pyx_INCREF(__pyx_v_obj_or_func); __pyx_t_1 = __pyx_v_obj_or_func; } __pyx_v_obj = __pyx_t_1; __pyx_t_1 = 0;
+7545: valid_args = obj.__init__.__code__.co_varnames if hasattr(
__Pyx_TraceLine(7545,0,__PYX_ERR(0, 7545, __pyx_L1_error)) __pyx_t_2 = __Pyx_HasAttr(__pyx_v_obj, __pyx_n_u_init); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 7545, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_code); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_co_varnames); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7545, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } else {
+7546: obj, '__init__') else obj.__code__.co_varnames
__Pyx_TraceLine(7546,0,__PYX_ERR(0, 7546, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_code); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_co_varnames); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7546, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_v_valid_args = __pyx_t_1; __pyx_t_1 = 0;
7547:
7548: # Filter kwargs to separate valid from invalid ones
+7549: for key, value in kwargs.items():
__Pyx_TraceLine(7549,0,__PYX_ERR(0, 7549, __pyx_L1_error)) __pyx_t_7 = 0; __pyx_t_4 = __Pyx_dict_iterator(__pyx_v_kwargs, 1, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_6)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7549, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_4; __pyx_t_4 = 0; while (1) { __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_8, &__pyx_t_7, &__pyx_t_4, &__pyx_t_3, NULL, __pyx_t_6); if (unlikely(__pyx_t_9 == 0)) break; if (unlikely(__pyx_t_9 == -1)) __PYX_ERR(0, 7549, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_3); __pyx_t_3 = 0;
+7550: if key in valid_args:
__Pyx_TraceLine(7550,0,__PYX_ERR(0, 7550, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_key, __pyx_v_valid_args, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7550, __pyx_L1_error) if (__pyx_t_2) { /* … */ goto __pyx_L5; }
+7551: valid_kwargs[key] = value
__Pyx_TraceLine(7551,0,__PYX_ERR(0, 7551, __pyx_L1_error)) if (unlikely((PyDict_SetItem(__pyx_v_valid_kwargs, __pyx_v_key, __pyx_v_value) < 0))) __PYX_ERR(0, 7551, __pyx_L1_error)
7552: else:
+7553: not_valid_keys.append(key)
__Pyx_TraceLine(7553,0,__PYX_ERR(0, 7553, __pyx_L1_error)) /*else*/ { __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_not_valid_keys, __pyx_v_key); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 7553, __pyx_L1_error) } __pyx_L5:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7554:
7555: # Raise a warning for invalid kwargs, if required
+7556: if raise_warning and not_valid_keys:
__Pyx_TraceLine(7556,0,__PYX_ERR(0, 7556, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_raise_warning); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 7556, __pyx_L1_error) if (__pyx_t_11) { } else { __pyx_t_2 = __pyx_t_11; goto __pyx_L7_bool_binop_done; } __pyx_t_11 = (PyList_GET_SIZE(__pyx_v_not_valid_keys) != 0); __pyx_t_2 = __pyx_t_11; __pyx_L7_bool_binop_done:; if (__pyx_t_2) { /* … */ }
+7557: warning_msg = (f"Warning: '{', '.join(not_valid_keys)}' "
__Pyx_TraceLine(7557,0,__PYX_ERR(0, 7557, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Warning); __pyx_t_8 += 10; __Pyx_GIVEREF(__pyx_kp_u_Warning); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Warning); __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__258, __pyx_v_not_valid_keys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_12; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__279); __pyx_t_8 += 2; __Pyx_GIVEREF(__pyx_kp_u__279); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__279); /* … */ __Pyx_TraceLine(7557,0,__PYX_ERR(0, 7557, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 7, __pyx_t_8, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7557, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_warning_msg = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
+7558: f"{'is' if len(not_valid_keys) == 1 else 'are'} "
__Pyx_TraceLine(7558,0,__PYX_ERR(0, 7558, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyList_GET_SIZE(__pyx_v_not_valid_keys); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 7558, __pyx_L1_error) __pyx_t_2 = (__pyx_t_7 == 1); if (__pyx_t_2) { __Pyx_INCREF(__pyx_n_u_is_2); __pyx_t_3 = __pyx_n_u_is_2; } else { __Pyx_INCREF(__pyx_n_u_are); __pyx_t_3 = __pyx_n_u_are; } __pyx_t_4 = __Pyx_PyUnicode_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7558, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) : __pyx_t_12; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_4); __pyx_t_4 = 0; __Pyx_INCREF(__pyx_kp_u_not_a_valid_keyword_argument_fo); __pyx_t_8 += 35; __Pyx_GIVEREF(__pyx_kp_u_not_a_valid_keyword_argument_fo); PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u_not_a_valid_keyword_argument_fo);
7559: "not a valid keyword argument "
+7560: f"for '{obj_or_func.__name__}'.")
__Pyx_TraceLine(7560,0,__PYX_ERR(0, 7560, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj_or_func, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7560, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_12; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u__170); __pyx_t_8 += 2; __Pyx_GIVEREF(__pyx_kp_u__170); PyTuple_SET_ITEM(__pyx_t_1, 6, __pyx_kp_u__170);
+7561: warnings.warn(warning_msg)
__Pyx_TraceLine(7561,0,__PYX_ERR(0, 7561, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_warnings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_warning_msg}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7562:
+7563: return valid_kwargs
__Pyx_TraceLine(7563,0,__PYX_ERR(0, 7563, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_valid_kwargs); __pyx_r = __pyx_v_valid_kwargs; goto __pyx_L0;
7564:
+7565: def projection_validator (X, Xt=None, columns =None ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_240projection_validator(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_239projection_validator, " Retrieve x, y coordinates of a datraframe ( X, Xt ) from columns \n names or indexes. \n \n If X or Xt are given as arrays, `columns` may hold integers from \n selecting the the coordinates 'x' and 'y'. \n \n Parameters \n ---------\n X: Ndarray ( M x N matrix where ``M=m-samples``, & ``N=n-features``)\n training set; Denotes data that is observed at training and prediction \n time, used as independent variables in learning. The notation \n is uppercase to denote that it is ordinarily a matrix. When a matrix, \n each sample may be represented by a feature vector, or a vector of \n precomputed (dis)similarity with each training sample. \n\n Xt: Ndarray ( M x N matrix where ``M=m-samples``, & ``N=n-features``)\n Shorthand for \"test set\"; data that is observed at testing and \n prediction time, used as independent variables in learning. The \n notation is uppercase to denote that it is ordinarily a matrix.\n columns: list of str or index, optional \n columns is usefull when a dataframe is given with a dimension size \n greater than 2. If such data is passed to `X` or `Xt`, columns must\n hold the name to consider as 'easting', 'northing' when UTM \n coordinates are given or 'latitude' , 'longitude' when latlon are \n given. \n If dimension size is greater than 2 and columns is None , an error \n will raises to prevent the user to provide the index for 'y' and 'x' \n coordinated retrieval. \n \n Returns \n -------\n ( x, y, xt, yt ), (xname, yname, xtname, ytname), Tuple of coordinate \n arrays and coordinate labels \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_240projection_validator = {"projection_validator", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_240projection_validator, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_239projection_validator}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_240projection_validator(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_X = 0; PyObject *__pyx_v_Xt = 0; PyObject *__pyx_v_columns = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("projection_validator (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,&__pyx_n_s_Xt,&__pyx_n_s_columns,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_X)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7565, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_Xt); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7565, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7565, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "projection_validator") < 0)) __PYX_ERR(0, 7565, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_X = values[0]; __pyx_v_Xt = values[1]; __pyx_v_columns = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("projection_validator", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 7565, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.projection_validator", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_239projection_validator(__pyx_self, __pyx_v_X, __pyx_v_Xt, __pyx_v_columns); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_239projection_validator(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_X, PyObject *__pyx_v_Xt, PyObject *__pyx_v_columns) { PyObject *__pyx_v_init_none = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_xt = NULL; PyObject *__pyx_v_yt = NULL; PyObject *__pyx_v_xname = NULL; PyObject *__pyx_v_yname = NULL; PyObject *__pyx_v_xtname = NULL; PyObject *__pyx_v_ytname = NULL; PyObject *__pyx_v_m = NULL; PyObject *__pyx_v_ms = NULL; CYTHON_UNUSED PyObject *__pyx_v__ = NULL; CYTHON_UNUSED long __pyx_9genexpr73__pyx_v_i; CYTHON_UNUSED long __pyx_9genexpr74__pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__280) __Pyx_TraceCall("projection_validator", __pyx_f[0], 7565, 0, __PYX_ERR(0, 7565, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_X); __Pyx_INCREF(__pyx_v_Xt); __Pyx_INCREF(__pyx_v_columns); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.projection_validator", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_init_none); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_xt); __Pyx_XDECREF(__pyx_v_yt); __Pyx_XDECREF(__pyx_v_xname); __Pyx_XDECREF(__pyx_v_yname); __Pyx_XDECREF(__pyx_v_xtname); __Pyx_XDECREF(__pyx_v_ytname); __Pyx_XDECREF(__pyx_v_m); __Pyx_XDECREF(__pyx_v_ms); __Pyx_XDECREF(__pyx_v__); __Pyx_XDECREF(__pyx_v_X); __Pyx_XDECREF(__pyx_v_Xt); __Pyx_XDECREF(__pyx_v_columns); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__522 = PyTuple_Pack(17, __pyx_n_s_X, __pyx_n_s_Xt, __pyx_n_s_columns, __pyx_n_s_init_none, __pyx_n_s_x, __pyx_n_s_y_4, __pyx_n_s_xt, __pyx_n_s_yt, __pyx_n_s_xname, __pyx_n_s_yname, __pyx_n_s_xtname, __pyx_n_s_ytname, __pyx_n_s_m_2, __pyx_n_s_ms, __pyx_n_s__8, __pyx_n_s_i, __pyx_n_s_i); if (unlikely(!__pyx_tuple__522)) __PYX_ERR(0, 7565, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__522); __Pyx_GIVEREF(__pyx_tuple__522); /* … */ __Pyx_TraceLine(7565,0,__PYX_ERR(0, 7565, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_240projection_validator, 0, __pyx_n_s_projection_validator, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__280)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__226); if (PyDict_SetItem(__pyx_d, __pyx_n_s_projection_validator, __pyx_t_5) < 0) __PYX_ERR(0, 7565, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__280 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 17, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__522, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_projection_validator, 7565, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__280)) __PYX_ERR(0, 7565, __pyx_L1_error)
7566: """ Retrieve x, y coordinates of a datraframe ( X, Xt ) from columns
7567: names or indexes.
7568:
7569: If X or Xt are given as arrays, `columns` may hold integers from
7570: selecting the the coordinates 'x' and 'y'.
7571:
7572: Parameters
7573: ---------
7574: X: Ndarray ( M x N matrix where ``M=m-samples``, & ``N=n-features``)
7575: training set; Denotes data that is observed at training and prediction
7576: time, used as independent variables in learning. The notation
7577: is uppercase to denote that it is ordinarily a matrix. When a matrix,
7578: each sample may be represented by a feature vector, or a vector of
7579: precomputed (dis)similarity with each training sample.
7580:
7581: Xt: Ndarray ( M x N matrix where ``M=m-samples``, & ``N=n-features``)
7582: Shorthand for "test set"; data that is observed at testing and
7583: prediction time, used as independent variables in learning. The
7584: notation is uppercase to denote that it is ordinarily a matrix.
7585: columns: list of str or index, optional
7586: columns is usefull when a dataframe is given with a dimension size
7587: greater than 2. If such data is passed to `X` or `Xt`, columns must
7588: hold the name to consider as 'easting', 'northing' when UTM
7589: coordinates are given or 'latitude' , 'longitude' when latlon are
7590: given.
7591: If dimension size is greater than 2 and columns is None , an error
7592: will raises to prevent the user to provide the index for 'y' and 'x'
7593: coordinated retrieval.
7594:
7595: Returns
7596: -------
7597: ( x, y, xt, yt ), (xname, yname, xtname, ytname), Tuple of coordinate
7598: arrays and coordinate labels
7599:
7600: """
7601: # initialize arrays and names
+7602: init_none = [None for i in range (4)]
__Pyx_TraceLine(7602,0,__PYX_ERR(0, 7602, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7602, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); for (__pyx_t_2 = 0; __pyx_t_2 < 4; __pyx_t_2+=1) { __pyx_9genexpr73__pyx_v_i = __pyx_t_2; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)Py_None))) __PYX_ERR(0, 7602, __pyx_L1_error) } } /* exit inner scope */ __pyx_v_init_none = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+7603: x,y, xt, yt = init_none
__Pyx_TraceLine(7603,0,__PYX_ERR(0, 7603, __pyx_L1_error)) if (1) { PyObject* sequence = __pyx_v_init_none; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7603, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); __pyx_t_4 = PyList_GET_ITEM(sequence, 2); __pyx_t_5 = PyList_GET_ITEM(sequence, 3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7603, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif } __pyx_v_x = __pyx_t_1; __pyx_t_1 = 0; __pyx_v_y = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_xt = __pyx_t_4; __pyx_t_4 = 0; __pyx_v_yt = __pyx_t_5; __pyx_t_5 = 0;
+7604: xname,yname, xtname, ytname = init_none
__Pyx_TraceLine(7604,0,__PYX_ERR(0, 7604, __pyx_L1_error)) if (1) { PyObject* sequence = __pyx_v_init_none; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7604, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); __pyx_t_3 = PyList_GET_ITEM(sequence, 2); __pyx_t_1 = PyList_GET_ITEM(sequence, 3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_4,&__pyx_t_3,&__pyx_t_1}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7604, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif } __pyx_v_xname = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_yname = __pyx_t_4; __pyx_t_4 = 0; __pyx_v_xtname = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_ytname = __pyx_t_1; __pyx_t_1 = 0;
7605:
+7606: m="{0} must be an iterable object, not {1!r}"
__Pyx_TraceLine(7606,0,__PYX_ERR(0, 7606, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_0_must_be_an_iterable_object_no); __pyx_v_m = __pyx_kp_u_0_must_be_an_iterable_object_no;
+7607: ms= ("{!r} is given while columns are not supplied. set the list of "
__Pyx_TraceLine(7607,0,__PYX_ERR(0, 7607, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_r_is_given_while_columns_are_no); __pyx_v_ms = __pyx_kp_u_r_is_given_while_columns_are_no;
7608: " feature names or indexes to fetch 'x' and 'y' coordinate arrays." )
7609:
7610: # validate X if X is np.array or dataframe
+7611: X =_assert_all_types(X, np.ndarray, pd.DataFrame )
__Pyx_TraceLine(7611,0,__PYX_ERR(0, 7611, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_v_X, __pyx_t_5, __pyx_t_6}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 3+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7611, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_X, __pyx_t_1); __pyx_t_1 = 0;
7612:
+7613: if Xt is not None:
__Pyx_TraceLine(7613,0,__PYX_ERR(0, 7613, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_Xt != Py_None); if (__pyx_t_8) { /* … */ }
7614: # validate Xt if Xt is np.array or dataframe
+7615: Xt = _assert_all_types(Xt, np.ndarray, pd.DataFrame)
__Pyx_TraceLine(7615,0,__PYX_ERR(0, 7615, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_assert_all_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_v_Xt, __pyx_t_5, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 3+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_Xt, __pyx_t_1); __pyx_t_1 = 0;
7616:
+7617: if columns is not None:
__Pyx_TraceLine(7617,0,__PYX_ERR(0, 7617, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_columns != Py_None); if (__pyx_t_8) { /* … */ }
+7618: if isinstance (columns, str):
__Pyx_TraceLine(7618,0,__PYX_ERR(0, 7618, __pyx_L1_error)) __pyx_t_8 = PyUnicode_Check(__pyx_v_columns); if (__pyx_t_8) { /* … */ }
+7619: columns = str2columns(columns )
__Pyx_TraceLine(7619,0,__PYX_ERR(0, 7619, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_str2columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_columns}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_1); __pyx_t_1 = 0;
7620:
+7621: if not is_iterable(columns):
__Pyx_TraceLine(7621,0,__PYX_ERR(0, 7621, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_columns}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7621, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 7621, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = (!__pyx_t_8); if (unlikely(__pyx_t_9)) { /* … */ }
+7622: raise ValueError(m.format('columns', type(columns).__name__))
__Pyx_TraceLine(7622,0,__PYX_ERR(0, 7622, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_columns)), __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_CallUnboundCMethod2(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_m, __pyx_n_u_columns, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7622, __pyx_L1_error)
7623:
+7624: columns = list(columns) + [ None for i in range (5)]
__Pyx_TraceLine(7624,0,__PYX_ERR(0, 7624, __pyx_L1_error)) __pyx_t_1 = PySequence_List(__pyx_v_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); for (__pyx_t_2 = 0; __pyx_t_2 < 5; __pyx_t_2+=1) { __pyx_9genexpr74__pyx_v_i = __pyx_t_2; if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)Py_None))) __PYX_ERR(0, 7624, __pyx_L1_error) } } /* exit inner scope */ __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7624, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_4); __pyx_t_4 = 0;
+7625: xname , yname, xtname, ytname , *_= columns
__Pyx_TraceLine(7625,0,__PYX_ERR(0, 7625, __pyx_L1_error)) { Py_ssize_t index = -1; PyObject** temps[5] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_1,&__pyx_t_5}; __pyx_t_6 = PyObject_GetIter(__pyx_v_columns); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_10(__pyx_t_6); if (unlikely(!item)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } goto __pyx_L12_unpacking_done; __pyx_L11_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7625, __pyx_L1_error) __pyx_L12_unpacking_done:; } __pyx_t_11 = PySequence_List(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7625, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_xname, __pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_yname, __pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_xtname, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_ytname, __pyx_t_5); __pyx_t_5 = 0; __pyx_v__ = ((PyObject*)__pyx_t_11); __pyx_t_11 = 0;
7626:
+7627: if isinstance(X, pd.DataFrame):
__Pyx_TraceLine(7627,0,__PYX_ERR(0, 7627, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_pd); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7627, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_9 = PyObject_IsInstance(__pyx_v_X, __pyx_t_5); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 7627, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_9) { /* … */ goto __pyx_L13; }
+7628: x, xname, y, yname = _validate_columns(X, [xname, yname])
__Pyx_TraceLine(7628,0,__PYX_ERR(0, 7628, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_validate_columns); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_xname)) __PYX_ERR(0, 7628, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_yname)) __PYX_ERR(0, 7628, __pyx_L1_error); __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_X, __pyx_t_1}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7628, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_11 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); __pyx_t_3 = PyList_GET_ITEM(sequence, 2); __pyx_t_4 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_11,&__pyx_t_1,&__pyx_t_3,&__pyx_t_4}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7628, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_11,&__pyx_t_1,&__pyx_t_3,&__pyx_t_4}; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7628, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_10(__pyx_t_6); if (unlikely(!item)) goto __pyx_L14_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 4) < 0) __PYX_ERR(0, 7628, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L15_unpacking_done; __pyx_L14_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7628, __pyx_L1_error) __pyx_L15_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF_SET(__pyx_v_xname, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_yname, __pyx_t_4); __pyx_t_4 = 0;
7629:
+7630: elif isinstance(X, np.ndarray):
__Pyx_TraceLine(7630,0,__PYX_ERR(0, 7630, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7630, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7630, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_9 = PyObject_IsInstance(__pyx_v_X, __pyx_t_4); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 7630, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_9) { /* … */ } __pyx_L13:;
+7631: x, y = _is_valid_coordinate_arrays (X, xname, yname )
__Pyx_TraceLine(7631,0,__PYX_ERR(0, 7631, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_is_valid_coordinate_arrays); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_v_X, __pyx_v_xname, __pyx_v_yname}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 3+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7631, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_3 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L16_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_3 = __pyx_t_10(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L16_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_1), 2) < 0) __PYX_ERR(0, 7631, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L17_unpacking_done; __pyx_L16_unpacking_failed:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7631, __pyx_L1_error) __pyx_L17_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_x, __pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_y, __pyx_t_3); __pyx_t_3 = 0;
7632:
7633:
+7634: if isinstance (Xt, pd.DataFrame) :
__Pyx_TraceLine(7634,0,__PYX_ERR(0, 7634, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_pd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7634, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = PyObject_IsInstance(__pyx_v_Xt, __pyx_t_3); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 7634, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_9) { /* … */ goto __pyx_L18; }
7635: # the test set holds the same feature names
7636: # as the train set
+7637: if xtname is None:
__Pyx_TraceLine(7637,0,__PYX_ERR(0, 7637, __pyx_L1_error)) __pyx_t_9 = (__pyx_v_xtname == Py_None); if (__pyx_t_9) { /* … */ }
+7638: xtname = xname
__Pyx_TraceLine(7638,0,__PYX_ERR(0, 7638, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_xname); __Pyx_DECREF_SET(__pyx_v_xtname, __pyx_v_xname);
+7639: if ytname is None:
__Pyx_TraceLine(7639,0,__PYX_ERR(0, 7639, __pyx_L1_error)) __pyx_t_9 = (__pyx_v_ytname == Py_None); if (__pyx_t_9) { /* … */ }
+7640: ytname = yname
__Pyx_TraceLine(7640,0,__PYX_ERR(0, 7640, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_yname); __Pyx_DECREF_SET(__pyx_v_ytname, __pyx_v_yname);
7641:
+7642: xt, xtname, yt, ytname = _validate_columns(Xt, [xname, yname])
__Pyx_TraceLine(7642,0,__PYX_ERR(0, 7642, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_validate_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_v_xname)) __PYX_ERR(0, 7642, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 1, __pyx_v_yname)) __PYX_ERR(0, 7642, __pyx_L1_error); __pyx_t_1 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_v_Xt, __pyx_t_5}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7642, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_4 = PyList_GET_ITEM(sequence, 0); __pyx_t_5 = PyList_GET_ITEM(sequence, 1); __pyx_t_1 = PyList_GET_ITEM(sequence, 2); __pyx_t_11 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_11); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_1,&__pyx_t_11}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7642, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_5,&__pyx_t_1,&__pyx_t_11}; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7642, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_10(__pyx_t_6); if (unlikely(!item)) goto __pyx_L21_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 4) < 0) __PYX_ERR(0, 7642, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L22_unpacking_done; __pyx_L21_unpacking_failed:; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7642, __pyx_L1_error) __pyx_L22_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_xt, __pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_xtname, __pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_yt, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_ytname, __pyx_t_11); __pyx_t_11 = 0;
7643:
+7644: elif isinstance(Xt, np.ndarray):
__Pyx_TraceLine(7644,0,__PYX_ERR(0, 7644, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7644, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = PyObject_IsInstance(__pyx_v_Xt, __pyx_t_11); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 7644, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (__pyx_t_9) { /* … */ } __pyx_L18:;
7645:
+7646: if xtname is None:
__Pyx_TraceLine(7646,0,__PYX_ERR(0, 7646, __pyx_L1_error)) __pyx_t_9 = (__pyx_v_xtname == Py_None); if (__pyx_t_9) { /* … */ }
+7647: xtname = xname
__Pyx_TraceLine(7647,0,__PYX_ERR(0, 7647, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_xname); __Pyx_DECREF_SET(__pyx_v_xtname, __pyx_v_xname);
+7648: if ytname is None:
__Pyx_TraceLine(7648,0,__PYX_ERR(0, 7648, __pyx_L1_error)) __pyx_t_9 = (__pyx_v_ytname == Py_None); if (__pyx_t_9) { /* … */ }
+7649: ytname = yname
__Pyx_TraceLine(7649,0,__PYX_ERR(0, 7649, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_yname); __Pyx_DECREF_SET(__pyx_v_ytname, __pyx_v_yname);
7650:
+7651: xt, yt = _is_valid_coordinate_arrays (Xt, xtname, ytname , 'test')
__Pyx_TraceLine(7651,0,__PYX_ERR(0, 7651, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_is_valid_coordinate_arrays); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[5] = {__pyx_t_1, __pyx_v_Xt, __pyx_v_xtname, __pyx_v_ytname, __pyx_n_u_test}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 4+__pyx_t_7); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) { PyObject* sequence = __pyx_t_11; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7651, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } else { Py_ssize_t index = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7651, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); index = 0; __pyx_t_3 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L25_unpacking_failed; __Pyx_GOTREF(__pyx_t_3); index = 1; __pyx_t_1 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_1)) goto __pyx_L25_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_5), 2) < 0) __PYX_ERR(0, 7651, __pyx_L1_error) __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L26_unpacking_done; __pyx_L25_unpacking_failed:; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7651, __pyx_L1_error) __pyx_L26_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_xt, __pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_yt, __pyx_t_1); __pyx_t_1 = 0;
7652:
+7653: if (x is None) or (y is None):
__Pyx_TraceLine(7653,0,__PYX_ERR(0, 7653, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_x == Py_None); if (!__pyx_t_8) { } else { __pyx_t_9 = __pyx_t_8; goto __pyx_L28_bool_binop_done; } __pyx_t_8 = (__pyx_v_y == Py_None); __pyx_t_9 = __pyx_t_8; __pyx_L28_bool_binop_done:; if (unlikely(__pyx_t_9)) { /* … */ }
+7654: raise ValueError (ms.format('X'))
__Pyx_TraceLine(7654,0,__PYX_ERR(0, 7654, __pyx_L1_error)) __pyx_t_11 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_ms, __pyx_n_u_X); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7654, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7654, __pyx_L1_error)
+7655: if Xt is not None:
__Pyx_TraceLine(7655,0,__PYX_ERR(0, 7655, __pyx_L1_error)) __pyx_t_9 = (__pyx_v_Xt != Py_None); if (__pyx_t_9) { /* … */ }
+7656: if (xt is None) or (yt is None):
__Pyx_TraceLine(7656,0,__PYX_ERR(0, 7656, __pyx_L1_error)) __pyx_t_8 = (__pyx_v_xt == Py_None); if (!__pyx_t_8) { } else { __pyx_t_9 = __pyx_t_8; goto __pyx_L32_bool_binop_done; } __pyx_t_8 = (__pyx_v_yt == Py_None); __pyx_t_9 = __pyx_t_8; __pyx_L32_bool_binop_done:; if (__pyx_t_9) { /* … */ }
+7657: warnings.warn (ms.format('Xt'))
__Pyx_TraceLine(7657,0,__PYX_ERR(0, 7657, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_warnings); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_warn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_ms, __pyx_n_u_Xt); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_11}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7657, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7658:
+7659: return (x, y , xt, yt ) , (
__Pyx_TraceLine(7659,0,__PYX_ERR(0, 7659, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x)) __PYX_ERR(0, 7659, __pyx_L1_error); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_y)) __PYX_ERR(0, 7659, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xt); __Pyx_GIVEREF(__pyx_v_xt); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_xt)) __PYX_ERR(0, 7659, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yt); __Pyx_GIVEREF(__pyx_v_yt); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_yt)) __PYX_ERR(0, 7659, __pyx_L1_error); /* … */ __Pyx_TraceLine(7659,0,__PYX_ERR(0, 7659, __pyx_L1_error)) __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7659, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1)) __PYX_ERR(0, 7659, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3)) __PYX_ERR(0, 7659, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_11; __pyx_t_11 = 0; goto __pyx_L0;
+7660: xname, yname, xtname, ytname )
__Pyx_TraceLine(7660,0,__PYX_ERR(0, 7660, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_xname)) __PYX_ERR(0, 7660, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_yname)) __PYX_ERR(0, 7660, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xtname); __Pyx_GIVEREF(__pyx_v_xtname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_xtname)) __PYX_ERR(0, 7660, __pyx_L1_error); __Pyx_INCREF(__pyx_v_ytname); __Pyx_GIVEREF(__pyx_v_ytname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_ytname)) __PYX_ERR(0, 7660, __pyx_L1_error);
7661:
+7662: def _validate_columns0 (df, xni, yni ):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_242_validate_columns0(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_241_validate_columns0, " Validate the feature name in the dataframe using either the \n string litteral name of the index position in the columns.\n \n :param df: pandas.DataFrame- Dataframe with feature names as columns. \n :param xni: str, int- feature name or position index in the columns for \n x-coordinate \n :param yni: str, int- feature name or position index in the columns for \n y-coordinate \n \n :returns: (x, ni) Tuple of (pandas.Series, and names) for x and y \n coordinates respectively.\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_242_validate_columns0 = {"_validate_columns0", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_242_validate_columns0, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_241_validate_columns0}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_242_validate_columns0(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_xni = 0; PyObject *__pyx_v_yni = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_validate_columns0 (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_xni,&__pyx_n_s_yni,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7662, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_xni)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7662, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_validate_columns0", 1, 3, 3, 1); __PYX_ERR(0, 7662, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_yni)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7662, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_validate_columns0", 1, 3, 3, 2); __PYX_ERR(0, 7662, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_validate_columns0") < 0)) __PYX_ERR(0, 7662, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_df = values[0]; __pyx_v_xni = values[1]; __pyx_v_yni = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_validate_columns0", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 7662, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._validate_columns0", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_241_validate_columns0(__pyx_self, __pyx_v_df, __pyx_v_xni, __pyx_v_yni); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_241_validate_columns0(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_xni, PyObject *__pyx_v_yni) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 *__pyx_cur_scope; PyObject *__pyx_v__r = 0; PyObject *__pyx_v_xs = NULL; PyObject *__pyx_v_ys = NULL; PyObject *__pyx_v_ms = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_v_me = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__281) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 7662, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("_validate_columns0", __pyx_f[0], 7662, 0, __PYX_ERR(0, 7662, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_df = __pyx_v_df; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_df); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_df); __Pyx_INCREF(__pyx_v_xni); __Pyx_INCREF(__pyx_v_yni); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("gofast.tools.coreutils._validate_columns0", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__r); __Pyx_XDECREF(__pyx_v_xs); __Pyx_XDECREF(__pyx_v_ys); __Pyx_XDECREF(__pyx_v_ms); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_me); __Pyx_XDECREF(__pyx_v_xni); __Pyx_XDECREF(__pyx_v_yni); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__523 = PyTuple_Pack(10, __pyx_n_s_df, __pyx_n_s_xni, __pyx_n_s_yni, __pyx_n_s_r_2, __pyx_n_s_r_2, __pyx_n_s_xs, __pyx_n_s_ys, __pyx_n_s_ms, __pyx_n_s_e, __pyx_n_s_me); if (unlikely(!__pyx_tuple__523)) __PYX_ERR(0, 7662, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__523); __Pyx_GIVEREF(__pyx_tuple__523); /* … */ __Pyx_TraceLine(7662,0,__PYX_ERR(0, 7662, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_242_validate_columns0, 0, __pyx_n_s_validate_columns0, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__281)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7662, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_columns0, __pyx_t_5) < 0) __PYX_ERR(0, 7662, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__281 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__523, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_columns0, 7662, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__281)) __PYX_ERR(0, 7662, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 { PyObject_HEAD PyObject *__pyx_v_df; };
7663: """ Validate the feature name in the dataframe using either the
7664: string litteral name of the index position in the columns.
7665:
7666: :param df: pandas.DataFrame- Dataframe with feature names as columns.
7667: :param xni: str, int- feature name or position index in the columns for
7668: x-coordinate
7669: :param yni: str, int- feature name or position index in the columns for
7670: y-coordinate
7671:
7672: :returns: (x, ni) Tuple of (pandas.Series, and names) for x and y
7673: coordinates respectively.
7674:
7675: """
+7676: def _r (ni):
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18_validate_columns0_1_r(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_18_validate_columns0_1_r = {"_r", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_18_validate_columns0_1_r, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18_validate_columns0_1_r(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_ni = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("_r (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ni,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ni)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7676, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_r") < 0)) __PYX_ERR(0, 7676, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_ni = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("_r", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 7676, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils._validate_columns0._r", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_18_validate_columns0__r(__pyx_self, __pyx_v_ni);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18_validate_columns0__r(PyObject *__pyx_self, PyObject *__pyx_v_ni) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 *__pyx_outer_scope;
PyObject *__pyx_v_s = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_31__validate_columns0 *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("_r", __pyx_f[0], 7676, 0, __PYX_ERR(0, 7676, __pyx_L1_error));
__Pyx_INCREF(__pyx_v_ni);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils._validate_columns0._r", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_s);
__Pyx_XDECREF(__pyx_v_ni);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__282 = PyTuple_Pack(2, __pyx_n_s_ni, __pyx_n_s_s_2); if (unlikely(!__pyx_tuple__282)) __PYX_ERR(0, 7676, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__282);
__Pyx_GIVEREF(__pyx_tuple__282);
/* … */
__Pyx_TraceLine(7676,0,__PYX_ERR(0, 7676, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_18_validate_columns0_1_r, 0, __pyx_n_s_validate_columns0_locals__r, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__283)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7676, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v__r = __pyx_t_1;
__pyx_t_1 = 0;
__pyx_codeobj__283 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__282, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_r_2, 7676, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__283)) __PYX_ERR(0, 7676, __pyx_L1_error)
+7677: if isinstance(ni, str): # feature name
__Pyx_TraceLine(7677,0,__PYX_ERR(0, 7677, __pyx_L1_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_ni); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+7678: exist_features(df, ni )
__Pyx_TraceLine(7678,0,__PYX_ERR(0, 7678, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_exist_features); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_cur_scope->__pyx_v_df)) { __Pyx_RaiseClosureNameError("df"); __PYX_ERR(0, 7678, __pyx_L1_error) } __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_df, __pyx_v_ni}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7678, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+7679: s = df[ni]
__Pyx_TraceLine(7679,0,__PYX_ERR(0, 7679, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_df)) { __Pyx_RaiseClosureNameError("df"); __PYX_ERR(0, 7679, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_df, __pyx_v_ni); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7679, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_s = __pyx_t_2; __pyx_t_2 = 0;
+7680: elif isinstance (ni, (int, float)):# feature index
__Pyx_TraceLine(7680,0,__PYX_ERR(0, 7680, __pyx_L1_error)) __pyx_t_6 = PyInt_Check(__pyx_v_ni); if (!__pyx_t_6) { } else { __pyx_t_1 = __pyx_t_6; goto __pyx_L4_bool_binop_done; } __pyx_t_6 = PyFloat_Check(__pyx_v_ni); __pyx_t_1 = __pyx_t_6; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ } __pyx_L3:;
+7681: s= df.iloc[:, int(ni)]
__Pyx_TraceLine(7681,0,__PYX_ERR(0, 7681, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_df)) { __Pyx_RaiseClosureNameError("df"); __PYX_ERR(0, 7681, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_df, __pyx_n_s_iloc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyNumber_Int(__pyx_v_ni); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__130)) __PYX_ERR(0, 7681, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3)) __PYX_ERR(0, 7681, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_s = __pyx_t_3; __pyx_t_3 = 0;
+7682: ni = s.name
__Pyx_TraceLine(7682,0,__PYX_ERR(0, 7682, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_name_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_ni, __pyx_t_3); __pyx_t_3 = 0;
+7683: return s, ni
__Pyx_TraceLine(7683,0,__PYX_ERR(0, 7683, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); if (unlikely(!__pyx_v_s)) { __Pyx_RaiseUnboundLocalError("s"); __PYX_ERR(0, 7683, __pyx_L1_error) } __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7683, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_s)) __PYX_ERR(0, 7683, __pyx_L1_error); __Pyx_INCREF(__pyx_v_ni); __Pyx_GIVEREF(__pyx_v_ni); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_ni)) __PYX_ERR(0, 7683, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
7684:
+7685: xs , ys = [None, None ]
__Pyx_TraceLine(7685,0,__PYX_ERR(0, 7685, __pyx_L1_error)) __pyx_t_1 = Py_None; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = Py_None; __Pyx_INCREF(__pyx_t_2); __pyx_v_xs = __pyx_t_1; __pyx_t_1 = 0; __pyx_v_ys = __pyx_t_2; __pyx_t_2 = 0;
+7686: if df.ndim ==1:
__Pyx_TraceLine(7686,0,__PYX_ERR(0, 7686, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_df, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 7686, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(__pyx_t_3)) { /* … */ }
+7687: raise ValueError ("Expect a dataframe of two dimensions, got '1'")
__Pyx_TraceLine(7687,0,__PYX_ERR(0, 7687, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__284, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 7687, __pyx_L1_error) /* … */ __pyx_tuple__284 = PyTuple_Pack(1, __pyx_kp_u_Expect_a_dataframe_of_two_dimens); if (unlikely(!__pyx_tuple__284)) __PYX_ERR(0, 7687, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__284); __Pyx_GIVEREF(__pyx_tuple__284);
7688:
+7689: elif df.shape[1]==2:
__Pyx_TraceLine(7689,0,__PYX_ERR(0, 7689, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_df, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 7689, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ goto __pyx_L3; }
+7690: warnings.warn("columns are not specify while array has dimension"
__Pyx_TraceLine(7690,0,__PYX_ERR(0, 7690, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_warnings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_warn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_kp_u_columns_are_not_specify_while_ar}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7691: "equals to 2. Expect indexes 0 and 1 for (x, y)"
7692: "coordinates respectively.")
+7693: xni= df.iloc[:, 0].name
__Pyx_TraceLine(7693,0,__PYX_ERR(0, 7693, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_df, __pyx_n_s_iloc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_tuple__136); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_xni, __pyx_t_1); __pyx_t_1 = 0;
+7694: yni= df.iloc[:, 1].name
__Pyx_TraceLine(7694,0,__PYX_ERR(0, 7694, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_df, __pyx_n_s_iloc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_tuple__285); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_name_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_yni, __pyx_t_1); __pyx_t_1 = 0; /* … */ __pyx_tuple__285 = PyTuple_Pack(2, __pyx_slice__130, __pyx_int_1); if (unlikely(!__pyx_tuple__285)) __PYX_ERR(0, 7694, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__285); __Pyx_GIVEREF(__pyx_tuple__285);
7695: else:
+7696: ms = ("The matrix of features is greater than 2. Need column names or"
__Pyx_TraceLine(7696,0,__PYX_ERR(0, 7696, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_kp_u_The_matrix_of_features_is_greate); __pyx_v_ms = __pyx_kp_u_The_matrix_of_features_is_greate;
7697: " indexes to retrieve the 'x' and 'y' coordinate arrays." )
+7698: e =' Only {!r} is given.'
__Pyx_TraceLine(7698,0,__PYX_ERR(0, 7698, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u_Only_r_is_given); __pyx_v_e = __pyx_kp_u_Only_r_is_given;
+7699: me=''
__Pyx_TraceLine(7699,0,__PYX_ERR(0, 7699, __pyx_L1_error)) __Pyx_INCREF(__pyx_kp_u__22); __pyx_v_me = __pyx_kp_u__22;
+7700: if xni is not None:
__Pyx_TraceLine(7700,0,__PYX_ERR(0, 7700, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_xni != Py_None); if (__pyx_t_3) { /* … */ }
+7701: me =e.format(xni)
__Pyx_TraceLine(7701,0,__PYX_ERR(0, 7701, __pyx_L1_error)) __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_e, __pyx_v_xni); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7701, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_me, __pyx_t_1); __pyx_t_1 = 0;
+7702: if yni is not None:
__Pyx_TraceLine(7702,0,__PYX_ERR(0, 7702, __pyx_L1_error)) __pyx_t_3 = (__pyx_v_yni != Py_None); if (__pyx_t_3) { /* … */ }
+7703: me=e.format(yni)
__Pyx_TraceLine(7703,0,__PYX_ERR(0, 7703, __pyx_L1_error)) __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_e, __pyx_v_yni); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_me, __pyx_t_1); __pyx_t_1 = 0;
7704:
+7705: if (xni is None) or (yni is None ):
__Pyx_TraceLine(7705,0,__PYX_ERR(0, 7705, __pyx_L1_error)) __pyx_t_6 = (__pyx_v_xni == Py_None); if (!__pyx_t_6) { } else { __pyx_t_3 = __pyx_t_6; goto __pyx_L7_bool_binop_done; } __pyx_t_6 = (__pyx_v_yni == Py_None); __pyx_t_3 = __pyx_t_6; __pyx_L7_bool_binop_done:; if (unlikely(__pyx_t_3)) { /* … */ } } __pyx_L3:;
+7706: raise ValueError (ms + me)
__Pyx_TraceLine(7706,0,__PYX_ERR(0, 7706, __pyx_L1_error)) __pyx_t_1 = PyNumber_Add(__pyx_v_ms, __pyx_v_me); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7706, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 7706, __pyx_L1_error)
7707:
+7708: xs, xni = _r (xni) ; ys, yni = _r (yni)
__Pyx_TraceLine(7708,0,__PYX_ERR(0, 7708, __pyx_L1_error)) __pyx_t_4 = __pyx_pf_6gofast_5tools_9coreutils_18_validate_columns0__r(__pyx_v__r, __pyx_v_xni); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7708, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); #else __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); index = 0; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); index = 1; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 7708, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L10_unpacking_done; __pyx_L9_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7708, __pyx_L1_error) __pyx_L10_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_xs, __pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF_SET(__pyx_v_xni, __pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = __pyx_pf_6gofast_5tools_9coreutils_18_validate_columns0__r(__pyx_v__r, __pyx_v_yni); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { PyObject* sequence = __pyx_t_4; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7708, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); } else { __pyx_t_2 = PyList_GET_ITEM(sequence, 0); __pyx_t_1 = PyList_GET_ITEM(sequence, 1); } __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); #else __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { Py_ssize_t index = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7708, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); index = 0; __pyx_t_2 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_2)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 1; __pyx_t_1 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_1); if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) __PYX_ERR(0, 7708, __pyx_L1_error) __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L12_unpacking_done; __pyx_L11_unpacking_failed:; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7708, __pyx_L1_error) __pyx_L12_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_ys, __pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_yni, __pyx_t_1); __pyx_t_1 = 0;
7709:
+7710: return xs, xni , ys, yni
__Pyx_TraceLine(7710,0,__PYX_ERR(0, 7710, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7710, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_xs); __Pyx_GIVEREF(__pyx_v_xs); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_xs)) __PYX_ERR(0, 7710, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xni); __Pyx_GIVEREF(__pyx_v_xni); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_xni)) __PYX_ERR(0, 7710, __pyx_L1_error); __Pyx_INCREF(__pyx_v_ys); __Pyx_GIVEREF(__pyx_v_ys); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_ys)) __PYX_ERR(0, 7710, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yni); __Pyx_GIVEREF(__pyx_v_yni); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_yni)) __PYX_ERR(0, 7710, __pyx_L1_error); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L0;
7711:
+7712: def _validate_array_indexer (arr, index):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_244_validate_array_indexer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_243_validate_array_indexer, " Select the appropriate coordinates (x,y) arrays from indexes. \n \n Index is used to retrieve the array of (x, y) coordinates if dimension \n of `arr` is greater than 2. Since we expect x, y coordinate for projecting \n coordinates, 1-d array `X` is not acceptable. \n \n :param arr: ndarray (n_samples, n_features) - if nfeatures is greater than \n 2 , indexes is needed to fetch the x, y coordinates . \n :param index: int, index to fetch x, and y coordinates in multi-dimension\n arrays. \n :returns: arr- x or y coordinates arrays. \n\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_244_validate_array_indexer = {"_validate_array_indexer", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_244_validate_array_indexer, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_243_validate_array_indexer}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_244_validate_array_indexer(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_index = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_validate_array_indexer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_index,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7712, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_index)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7712, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_validate_array_indexer", 1, 2, 2, 1); __PYX_ERR(0, 7712, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_validate_array_indexer") < 0)) __PYX_ERR(0, 7712, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_arr = values[0]; __pyx_v_index = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_validate_array_indexer", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 7712, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._validate_array_indexer", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_243_validate_array_indexer(__pyx_self, __pyx_v_arr, __pyx_v_index); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_243_validate_array_indexer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_index) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__286) __Pyx_TraceCall("_validate_array_indexer", __pyx_f[0], 7712, 0, __PYX_ERR(0, 7712, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils._validate_array_indexer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__524 = PyTuple_Pack(2, __pyx_n_s_arr, __pyx_n_s_index); if (unlikely(!__pyx_tuple__524)) __PYX_ERR(0, 7712, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__524); __Pyx_GIVEREF(__pyx_tuple__524); /* … */ __Pyx_TraceLine(7712,0,__PYX_ERR(0, 7712, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_244_validate_array_indexer, 0, __pyx_n_s_validate_array_indexer, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__286)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7712, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_array_indexer, __pyx_t_5) < 0) __PYX_ERR(0, 7712, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__286 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__524, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_array_indexer, 7712, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__286)) __PYX_ERR(0, 7712, __pyx_L1_error)
7713: """ Select the appropriate coordinates (x,y) arrays from indexes.
7714:
7715: Index is used to retrieve the array of (x, y) coordinates if dimension
7716: of `arr` is greater than 2. Since we expect x, y coordinate for projecting
7717: coordinates, 1-d array `X` is not acceptable.
7718:
7719: :param arr: ndarray (n_samples, n_features) - if nfeatures is greater than
7720: 2 , indexes is needed to fetch the x, y coordinates .
7721: :param index: int, index to fetch x, and y coordinates in multi-dimension
7722: arrays.
7723: :returns: arr- x or y coordinates arrays.
7724:
7725: """
+7726: if arr.ndim ==1:
__Pyx_TraceLine(7726,0,__PYX_ERR(0, 7726, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7726, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7726, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+7727: raise ValueError ("Expect an array of two dimensions.")
__Pyx_TraceLine(7727,0,__PYX_ERR(0, 7727, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__287, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7727, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7727, __pyx_L1_error) /* … */ __pyx_tuple__287 = PyTuple_Pack(1, __pyx_kp_u_Expect_an_array_of_two_dimension); if (unlikely(!__pyx_tuple__287)) __PYX_ERR(0, 7727, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__287); __Pyx_GIVEREF(__pyx_tuple__287);
+7728: if not isinstance (index, (float, int)):
__Pyx_TraceLine(7728,0,__PYX_ERR(0, 7728, __pyx_L1_error)) __pyx_t_3 = PyFloat_Check(__pyx_v_index); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L5_bool_binop_done; } __pyx_t_3 = PyInt_Check(__pyx_v_index); __pyx_t_2 = __pyx_t_3; __pyx_L5_bool_binop_done:; __pyx_t_3 = (!__pyx_t_2); if (unlikely(__pyx_t_3)) { /* … */ }
+7729: raise ValueError("index is needed to coordinate array with "
__Pyx_TraceLine(7729,0,__PYX_ERR(0, 7729, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__288, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7729, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7729, __pyx_L1_error) /* … */ __pyx_tuple__288 = PyTuple_Pack(1, __pyx_kp_u_index_is_needed_to_coordinate_ar); if (unlikely(!__pyx_tuple__288)) __PYX_ERR(0, 7729, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__288); __Pyx_GIVEREF(__pyx_tuple__288);
7730: "dimension greater than 2.")
7731:
+7732: return arr[:, int (index) ]
__Pyx_TraceLine(7732,0,__PYX_ERR(0, 7732, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_index); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__130)) __PYX_ERR(0, 7732, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1)) __PYX_ERR(0, 7732, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7732, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
7733:
+7734: def _is_valid_coordinate_arrays (arr, xind, yind, ptype ='train'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_246_is_valid_coordinate_arrays(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_245_is_valid_coordinate_arrays, " Check whether array is suitable for projecting i.e. whether \n x and y (both coordinates) can be retrived from `arr`.\n \n :param arr: ndarray (n_samples, n_features) - if nfeatures is greater than \n 2 , indexes is needed to fetch the x, y coordinates . \n \n :param xind: int, index to fetch x-coordinate in multi-dimension\n arrays. \n :param yind: int, index to fetch y-coordinate in multi-dimension\n arrays\n :param ptype: str, default='train', specify whether the array passed is \n training or test sets. \n :returns: (x, y)- array-like of x and y coordinates. \n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_246_is_valid_coordinate_arrays = {"_is_valid_coordinate_arrays", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_246_is_valid_coordinate_arrays, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_245_is_valid_coordinate_arrays}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_246_is_valid_coordinate_arrays(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_xind = 0; PyObject *__pyx_v_yind = 0; PyObject *__pyx_v_ptype = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_is_valid_coordinate_arrays (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_xind,&__pyx_n_s_yind,&__pyx_n_s_ptype,0}; PyObject* values[4] = {0,0,0,0}; values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_train))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7734, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_xind)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7734, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_is_valid_coordinate_arrays", 0, 3, 4, 1); __PYX_ERR(0, 7734, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_yind)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7734, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_is_valid_coordinate_arrays", 0, 3, 4, 2); __PYX_ERR(0, 7734, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ptype); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7734, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_is_valid_coordinate_arrays") < 0)) __PYX_ERR(0, 7734, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_xind = values[1]; __pyx_v_yind = values[2]; __pyx_v_ptype = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_is_valid_coordinate_arrays", 0, 3, 4, __pyx_nargs); __PYX_ERR(0, 7734, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._is_valid_coordinate_arrays", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_245_is_valid_coordinate_arrays(__pyx_self, __pyx_v_arr, __pyx_v_xind, __pyx_v_yind, __pyx_v_ptype); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_245_is_valid_coordinate_arrays(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_xind, PyObject *__pyx_v_yind, PyObject *__pyx_v_ptype) { PyObject *__pyx_v_xn = NULL; PyObject *__pyx_v_yn = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_msg = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__289) __Pyx_TraceCall("_is_valid_coordinate_arrays", __pyx_f[0], 7734, 0, __PYX_ERR(0, 7734, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils._is_valid_coordinate_arrays", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_xn); __Pyx_XDECREF(__pyx_v_yn); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_msg); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__525 = PyTuple_Pack(9, __pyx_n_s_arr, __pyx_n_s_xind, __pyx_n_s_yind, __pyx_n_s_ptype, __pyx_n_s_xn, __pyx_n_s_yn, __pyx_n_s_x, __pyx_n_s_y_4, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__525)) __PYX_ERR(0, 7734, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__525); __Pyx_GIVEREF(__pyx_tuple__525); __pyx_codeobj__289 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__525, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_is_valid_coordinate_arrays, 7734, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__289)) __PYX_ERR(0, 7734, __pyx_L1_error) /* … */ __Pyx_TraceLine(7734,0,__PYX_ERR(0, 7734, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_246_is_valid_coordinate_arrays, 0, __pyx_n_s_is_valid_coordinate_arrays, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__289)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7734, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__526); if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_valid_coordinate_arrays, __pyx_t_5) < 0) __PYX_ERR(0, 7734, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__526 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_train)); if (unlikely(!__pyx_tuple__526)) __PYX_ERR(0, 7734, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__526); __Pyx_GIVEREF(__pyx_tuple__526);
7735: """ Check whether array is suitable for projecting i.e. whether
7736: x and y (both coordinates) can be retrived from `arr`.
7737:
7738: :param arr: ndarray (n_samples, n_features) - if nfeatures is greater than
7739: 2 , indexes is needed to fetch the x, y coordinates .
7740:
7741: :param xind: int, index to fetch x-coordinate in multi-dimension
7742: arrays.
7743: :param yind: int, index to fetch y-coordinate in multi-dimension
7744: arrays
7745: :param ptype: str, default='train', specify whether the array passed is
7746: training or test sets.
7747: :returns: (x, y)- array-like of x and y coordinates.
7748:
7749: """
+7750: xn, yn =('x', 'y') if ptype =='train' else ('xt', 'yt')
__Pyx_TraceLine(7750,0,__PYX_ERR(0, 7750, __pyx_L1_error)) __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_v_ptype, __pyx_n_u_train, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7750, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_tuple__290); __pyx_t_1 = __pyx_tuple__290; } else { /* … */ __pyx_tuple__290 = PyTuple_Pack(2, __pyx_n_u_x, __pyx_n_u_y_4); if (unlikely(!__pyx_tuple__290)) __PYX_ERR(0, 7750, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__290); __Pyx_GIVEREF(__pyx_tuple__290); __Pyx_INCREF(__pyx_tuple__291); __pyx_t_1 = __pyx_tuple__291; } if (likely(__pyx_t_1 != Py_None)) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7750, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 7750, __pyx_L1_error) } __pyx_v_xn = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_yn = __pyx_t_4; __pyx_t_4 = 0; __pyx_tuple__291 = PyTuple_Pack(2, __pyx_n_u_xt, __pyx_n_u_yt); if (unlikely(!__pyx_tuple__291)) __PYX_ERR(0, 7750, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__291); __Pyx_GIVEREF(__pyx_tuple__291);
+7751: if arr.ndim ==1:
__Pyx_TraceLine(7751,0,__PYX_ERR(0, 7751, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7751, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_1, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7751, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+7752: raise ValueError ("Expect an array of two dimensions.")
__Pyx_TraceLine(7752,0,__PYX_ERR(0, 7752, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__287, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7752, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7752, __pyx_L1_error)
7753:
+7754: elif arr.shape[1] ==2 :
__Pyx_TraceLine(7754,0,__PYX_ERR(0, 7754, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7754, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_2 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_4, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 7754, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L3; }
+7755: x, y = arr[:, 0], arr[:, 1]
__Pyx_TraceLine(7755,0,__PYX_ERR(0, 7755, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_tuple__136); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_v_arr, __pyx_tuple__285); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7755, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_x = __pyx_t_4; __pyx_t_4 = 0; __pyx_v_y = __pyx_t_1; __pyx_t_1 = 0;
7756:
7757: else :
+7758: msg=("The matrix of features is greater than 2; Need index to "
__Pyx_TraceLine(7758,0,__PYX_ERR(0, 7758, __pyx_L1_error)) /*else*/ { __Pyx_INCREF(__pyx_kp_u_The_matrix_of_features_is_greate_2); __pyx_v_msg = __pyx_kp_u_The_matrix_of_features_is_greate_2;
7759: " retrieve the {!r} coordinate array in param 'column'.")
7760:
+7761: if xind is None:
__Pyx_TraceLine(7761,0,__PYX_ERR(0, 7761, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_xind == Py_None); if (unlikely(__pyx_t_2)) { /* … */ }
+7762: raise ValueError(msg.format(xn))
__Pyx_TraceLine(7762,0,__PYX_ERR(0, 7762, __pyx_L1_error)) __pyx_t_1 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_msg, __pyx_v_xn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7762, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 7762, __pyx_L1_error)
+7763: else : x = _validate_array_indexer(arr, xind)
__Pyx_TraceLine(7763,0,__PYX_ERR(0, 7763, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_validate_array_indexer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_arr, __pyx_v_xind}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_v_x = __pyx_t_4; __pyx_t_4 = 0; }
+7764: if yind is None :
__Pyx_TraceLine(7764,0,__PYX_ERR(0, 7764, __pyx_L1_error)) __pyx_t_2 = (__pyx_v_yind == Py_None); if (unlikely(__pyx_t_2)) { /* … */ }
+7765: raise ValueError(msg.format(yn))
__Pyx_TraceLine(7765,0,__PYX_ERR(0, 7765, __pyx_L1_error)) __pyx_t_4 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_msg, __pyx_v_yn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7765, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 7765, __pyx_L1_error)
+7766: else : y = _validate_array_indexer(arr, yind)
__Pyx_TraceLine(7766,0,__PYX_ERR(0, 7766, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_validate_array_indexer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_arr, __pyx_v_yind}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7766, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_y = __pyx_t_1; __pyx_t_1 = 0; } } __pyx_L3:;
7767:
+7768: return x, y
__Pyx_TraceLine(7768,0,__PYX_ERR(0, 7768, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x)) __PYX_ERR(0, 7768, __pyx_L1_error); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_y)) __PYX_ERR(0, 7768, __pyx_L1_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
7769:
+7770: def extract_coordinates(X, Xt=None, columns=None):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_248extract_coordinates(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_247extract_coordinates, "\n Extracts 'x' and 'y' coordinate arrays from training (X) and optionally\n test (Xt) datasets. \n \n Supports input as NumPy arrays or pandas DataFrames. When dealing\n with DataFrames, `columns` can specify which columns to use for coordinates.\n\n Parameters\n ----------\n X : ndarray or DataFrame\n Training dataset with shape (M, N) where M is the number of samples and\n N is the number of features. It represents the observed data used as\n independent variables in learning.\n Xt : ndarray or DataFrame, optional\n Test dataset with shape (M, N) where M is the number of samples and\n N is the number of features. It represents the data observed at testing\n and prediction time, used as independent variables in learning.\n columns : list of str or int, optional\n Specifies the columns to use for 'x' and 'y' coordinates. Necessary when\n X or Xt are DataFrames with more than 2 dimensions or when selecting specific\n features from NumPy arrays.\n\n Returns\n -------\n tuple of arrays\n A tuple containing the 'x' and 'y' coordinates from the training set and, \n if provided, the test set. Formatted as (x, y, xt, yt).\n tuple of str or None\n A tuple containing the names or indices of the 'x' and 'y' columns \n for the training and test sets. Formatted as (xname, yname, xtname, ytname).\n Values are None if not applicable or not provided.\n\n Raises\n ------\n ValueError\n If `columns` is not iterable, not provided for DataFrames with more \n than 2 dimensions, or if X or Xt cannot be validated as coordinate arrays.\n\n Examples\n --------\n >>> import numpy as np \n >>> from gofast.tools.coreutils import extract_coordinates\n >>> X = np.array([[1, 2], [3, 4]])\n >>> Xt = np.array([[5, 6], [7, 8]])\n >>> extract_coordinates(X, Xt )\n ((array([1, 3]), array([2, 4]), array([5, 7]), arra""y([6, 8])), (0, 1, 0, 1))\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_248extract_coordinates = {"extract_coordinates", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_248extract_coordinates, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_247extract_coordinates}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_248extract_coordinates(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_X = 0; PyObject *__pyx_v_Xt = 0; PyObject *__pyx_v_columns = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("extract_coordinates (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_X,&__pyx_n_s_Xt,&__pyx_n_s_columns,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_X)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7770, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_Xt); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7770, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7770, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "extract_coordinates") < 0)) __PYX_ERR(0, 7770, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_X = values[0]; __pyx_v_Xt = values[1]; __pyx_v_columns = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("extract_coordinates", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 7770, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.extract_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_247extract_coordinates(__pyx_self, __pyx_v_X, __pyx_v_Xt, __pyx_v_columns); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_247extract_coordinates(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_X, PyObject *__pyx_v_Xt, PyObject *__pyx_v_columns) { PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_xname = NULL; PyObject *__pyx_v_yname = NULL; PyObject *__pyx_v_xt = NULL; PyObject *__pyx_v_yt = NULL; PyObject *__pyx_v_xtname = NULL; PyObject *__pyx_v_ytname = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__292) __Pyx_TraceCall("extract_coordinates", __pyx_f[0], 7770, 0, __PYX_ERR(0, 7770, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_columns); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.extract_coordinates", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_xname); __Pyx_XDECREF(__pyx_v_yname); __Pyx_XDECREF(__pyx_v_xt); __Pyx_XDECREF(__pyx_v_yt); __Pyx_XDECREF(__pyx_v_xtname); __Pyx_XDECREF(__pyx_v_ytname); __Pyx_XDECREF(__pyx_v_columns); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__527 = PyTuple_Pack(11, __pyx_n_s_X, __pyx_n_s_Xt, __pyx_n_s_columns, __pyx_n_s_x, __pyx_n_s_y_4, __pyx_n_s_xname, __pyx_n_s_yname, __pyx_n_s_xt, __pyx_n_s_yt, __pyx_n_s_xtname, __pyx_n_s_ytname); if (unlikely(!__pyx_tuple__527)) __PYX_ERR(0, 7770, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__527); __Pyx_GIVEREF(__pyx_tuple__527); /* … */ __Pyx_TraceLine(7770,0,__PYX_ERR(0, 7770, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_248extract_coordinates, 0, __pyx_n_s_extract_coordinates, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__292)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7770, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__226); if (PyDict_SetItem(__pyx_d, __pyx_n_s_extract_coordinates, __pyx_t_5) < 0) __PYX_ERR(0, 7770, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__292 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__527, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_extract_coordinates, 7770, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__292)) __PYX_ERR(0, 7770, __pyx_L1_error)
7771: """
7772: Extracts 'x' and 'y' coordinate arrays from training (X) and optionally
7773: test (Xt) datasets.
7774:
7775: Supports input as NumPy arrays or pandas DataFrames. When dealing
7776: with DataFrames, `columns` can specify which columns to use for coordinates.
7777:
7778: Parameters
7779: ----------
7780: X : ndarray or DataFrame
7781: Training dataset with shape (M, N) where M is the number of samples and
7782: N is the number of features. It represents the observed data used as
7783: independent variables in learning.
7784: Xt : ndarray or DataFrame, optional
7785: Test dataset with shape (M, N) where M is the number of samples and
7786: N is the number of features. It represents the data observed at testing
7787: and prediction time, used as independent variables in learning.
7788: columns : list of str or int, optional
7789: Specifies the columns to use for 'x' and 'y' coordinates. Necessary when
7790: X or Xt are DataFrames with more than 2 dimensions or when selecting specific
7791: features from NumPy arrays.
7792:
7793: Returns
7794: -------
7795: tuple of arrays
7796: A tuple containing the 'x' and 'y' coordinates from the training set and,
7797: if provided, the test set. Formatted as (x, y, xt, yt).
7798: tuple of str or None
7799: A tuple containing the names or indices of the 'x' and 'y' columns
7800: for the training and test sets. Formatted as (xname, yname, xtname, ytname).
7801: Values are None if not applicable or not provided.
7802:
7803: Raises
7804: ------
7805: ValueError
7806: If `columns` is not iterable, not provided for DataFrames with more
7807: than 2 dimensions, or if X or Xt cannot be validated as coordinate arrays.
7808:
7809: Examples
7810: --------
7811: >>> import numpy as np
7812: >>> from gofast.tools.coreutils import extract_coordinates
7813: >>> X = np.array([[1, 2], [3, 4]])
7814: >>> Xt = np.array([[5, 6], [7, 8]])
7815: >>> extract_coordinates(X, Xt )
7816: ((array([1, 3]), array([2, 4]), array([5, 7]), array([6, 8])), (0, 1, 0, 1))
7817: """
+7818: if columns is None:
__Pyx_TraceLine(7818,0,__PYX_ERR(0, 7818, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_columns == Py_None); if (__pyx_t_1) { /* … */ }
+7819: if not isinstance ( X, pd.DataFrame) and X.shape[1]!=2:
__Pyx_TraceLine(7819,0,__PYX_ERR(0, 7819, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_v_X, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 7819, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (!__pyx_t_4); if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L5_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7819, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__Pyx_PyInt_BoolNeObjC(__pyx_t_2, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7819, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_5; __pyx_L5_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+7820: raise ValueError("Columns cannot be None when array is passed.")
__Pyx_TraceLine(7820,0,__PYX_ERR(0, 7820, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__293, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7820, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 7820, __pyx_L1_error) /* … */ __pyx_tuple__293 = PyTuple_Pack(1, __pyx_kp_u_Columns_cannot_be_None_when_arra); if (unlikely(!__pyx_tuple__293)) __PYX_ERR(0, 7820, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__293); __Pyx_GIVEREF(__pyx_tuple__293);
+7821: if isinstance(X, np.ndarray) and X.shape[1]==2:
__Pyx_TraceLine(7821,0,__PYX_ERR(0, 7821, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = PyObject_IsInstance(__pyx_v_X, __pyx_t_3); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 7821, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L8_bool_binop_done; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7821, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 7821, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_5; __pyx_L8_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+7822: columns =[0, 1]
__Pyx_TraceLine(7822,0,__PYX_ERR(0, 7822, __pyx_L1_error)) __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_int_0)) __PYX_ERR(0, 7822, __pyx_L1_error); __Pyx_INCREF(__pyx_int_1); __Pyx_GIVEREF(__pyx_int_1); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_int_1)) __PYX_ERR(0, 7822, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_2); __pyx_t_2 = 0;
7823:
+7824: columns = columns or ( list(X.columns) if isinstance (
__Pyx_TraceLine(7824,0,__PYX_ERR(0, 7824, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_columns); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 7824, __pyx_L1_error) if (!__pyx_t_1) { } else { __Pyx_INCREF(__pyx_v_columns); __pyx_t_2 = __pyx_v_columns; goto __pyx_L10_bool_binop_done; } /* … */ __Pyx_TraceLine(7824,0,__PYX_ERR(0, 7824, __pyx_L1_error)) __pyx_t_1 = PyObject_IsInstance(__pyx_v_X, __pyx_t_7); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 7824, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_1) { __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_X, __pyx_n_s_columns); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PySequence_ListKeepNew(__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7824, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } else {
+7825: X, pd.DataFrame ) else columns )
__Pyx_TraceLine(7825,0,__PYX_ERR(0, 7825, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_pd); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7825, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __Pyx_TraceLine(7825,0,__PYX_ERR(0, 7825, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_columns); __pyx_t_3 = __pyx_v_columns; } __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_L10_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_columns, __pyx_t_2); __pyx_t_2 = 0;
7826:
+7827: if columns is None :
__Pyx_TraceLine(7827,0,__PYX_ERR(0, 7827, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_columns == Py_None); if (unlikely(__pyx_t_1)) { /* … */ }
+7828: raise ValueError("Columns parameter is required to specify"
__Pyx_TraceLine(7828,0,__PYX_ERR(0, 7828, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__294, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7828, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 7828, __pyx_L1_error) /* … */ __pyx_tuple__294 = PyTuple_Pack(1, __pyx_kp_u_Columns_parameter_is_required_to); if (unlikely(!__pyx_tuple__294)) __PYX_ERR(0, 7828, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__294); __Pyx_GIVEREF(__pyx_tuple__294);
7829: " 'x' and 'y' coordinates.")
7830:
+7831: if not isinstance(columns, (list, tuple)) or len(columns) != 2:
__Pyx_TraceLine(7831,0,__PYX_ERR(0, 7831, __pyx_L1_error)) __pyx_t_4 = PyList_Check(__pyx_v_columns); if (!__pyx_t_4) { } else { __pyx_t_5 = __pyx_t_4; goto __pyx_L16_bool_binop_done; } __pyx_t_4 = PyTuple_Check(__pyx_v_columns); __pyx_t_5 = __pyx_t_4; __pyx_L16_bool_binop_done:; __pyx_t_4 = (!__pyx_t_5); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L14_bool_binop_done; } __pyx_t_8 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 7831, __pyx_L1_error) __pyx_t_4 = (__pyx_t_8 != 2); __pyx_t_1 = __pyx_t_4; __pyx_L14_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+7832: raise ValueError("Columns parameter must be a list or tuple with "
__Pyx_TraceLine(7832,0,__PYX_ERR(0, 7832, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__295, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7832, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 7832, __pyx_L1_error) /* … */ __pyx_tuple__295 = PyTuple_Pack(1, __pyx_kp_u_Columns_parameter_must_be_a_list); if (unlikely(!__pyx_tuple__295)) __PYX_ERR(0, 7832, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__295); __Pyx_GIVEREF(__pyx_tuple__295);
7833: "exactly two elements for 'x' and 'y' coordinates.")
7834:
7835: # Process training dataset
+7836: x, y, xname, yname = _process_dataset(X, columns)
__Pyx_TraceLine(7836,0,__PYX_ERR(0, 7836, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_process_dataset); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7836, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_X, __pyx_v_columns}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7836, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7836, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_3 = PyList_GET_ITEM(sequence, 0); __pyx_t_6 = PyList_GET_ITEM(sequence, 1); __pyx_t_7 = PyList_GET_ITEM(sequence, 2); __pyx_t_10 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_10); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_6,&__pyx_t_7,&__pyx_t_10}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7836, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_6,&__pyx_t_7,&__pyx_t_10}; __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7836, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L18_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) __PYX_ERR(0, 7836, __pyx_L1_error) __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L19_unpacking_done; __pyx_L18_unpacking_failed:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7836, __pyx_L1_error) __pyx_L19_unpacking_done:; } __pyx_v_x = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_y = __pyx_t_6; __pyx_t_6 = 0; __pyx_v_xname = __pyx_t_7; __pyx_t_7 = 0; __pyx_v_yname = __pyx_t_10; __pyx_t_10 = 0;
7837:
7838: # Process test dataset, if provided
+7839: if Xt is not None:
__Pyx_TraceLine(7839,0,__PYX_ERR(0, 7839, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_Xt != Py_None); if (__pyx_t_1) { /* … */ goto __pyx_L20; }
+7840: xt, yt, xtname, ytname = _process_dataset(Xt, columns)
__Pyx_TraceLine(7840,0,__PYX_ERR(0, 7840, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_process_dataset); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_7 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_v_Xt, __pyx_v_columns}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7840, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_10 = PyList_GET_ITEM(sequence, 0); __pyx_t_7 = PyList_GET_ITEM(sequence, 1); __pyx_t_6 = PyList_GET_ITEM(sequence, 2); __pyx_t_3 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_3); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_7,&__pyx_t_6,&__pyx_t_3}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7840, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_7,&__pyx_t_6,&__pyx_t_3}; __pyx_t_11 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7840, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_12 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L21_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) __PYX_ERR(0, 7840, __pyx_L1_error) __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L22_unpacking_done; __pyx_L21_unpacking_failed:; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7840, __pyx_L1_error) __pyx_L22_unpacking_done:; } __pyx_v_xt = __pyx_t_10; __pyx_t_10 = 0; __pyx_v_yt = __pyx_t_7; __pyx_t_7 = 0; __pyx_v_xtname = __pyx_t_6; __pyx_t_6 = 0; __pyx_v_ytname = __pyx_t_3; __pyx_t_3 = 0;
7841: else:
+7842: xt, yt, xtname, ytname = None, None, None, None
__Pyx_TraceLine(7842,0,__PYX_ERR(0, 7842, __pyx_L1_error)) /*else*/ { __pyx_t_2 = Py_None; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = Py_None; __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = Py_None; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = Py_None; __Pyx_INCREF(__pyx_t_7); __pyx_v_xt = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_yt = __pyx_t_3; __pyx_t_3 = 0; __pyx_v_xtname = __pyx_t_6; __pyx_t_6 = 0; __pyx_v_ytname = __pyx_t_7; __pyx_t_7 = 0; } __pyx_L20:;
7843:
+7844: return (x, y, xt, yt), (xname, yname, xtname, ytname)
__Pyx_TraceLine(7844,0,__PYX_ERR(0, 7844, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_x)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_y)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xt); __Pyx_GIVEREF(__pyx_v_xt); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_xt)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yt); __Pyx_GIVEREF(__pyx_v_yt); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_yt)) __PYX_ERR(0, 7844, __pyx_L1_error); __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_xname)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_yname)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xtname); __Pyx_GIVEREF(__pyx_v_xtname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_xtname)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_INCREF(__pyx_v_ytname); __Pyx_GIVEREF(__pyx_v_ytname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_ytname)) __PYX_ERR(0, 7844, __pyx_L1_error); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 7844, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7)) __PYX_ERR(0, 7844, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_6)) __PYX_ERR(0, 7844, __pyx_L1_error); __pyx_t_7 = 0; __pyx_t_6 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
7845:
+7846: def _validate_columns(df, columns):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_250_validate_columns(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_249_validate_columns, "\n Validates and extracts x, y coordinates from a DataFrame based on column \n names or indices.\n \n Parameters\n ----------\n df : pandas.DataFrame\n The DataFrame from which to extract coordinate columns.\n columns : list of str or int\n The names or indices of the columns to extract as coordinates.\n \n Returns\n -------\n x, xname, y, yname : (pandas.Series, str/int, pandas.Series, str/int)\n The extracted x and y coordinate Series along with their column\n names or indices.\n \n Raises\n ------\n ValueError\n If the specified columns are not found in the DataFrame or if the \n columns list is not correctly specified.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_250_validate_columns = {"_validate_columns", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_250_validate_columns, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_249_validate_columns}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_250_validate_columns(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_columns = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_validate_columns (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_columns,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7846, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7846, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_validate_columns", 1, 2, 2, 1); __PYX_ERR(0, 7846, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_validate_columns") < 0)) __PYX_ERR(0, 7846, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_df = values[0]; __pyx_v_columns = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_validate_columns", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 7846, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._validate_columns", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_249_validate_columns(__pyx_self, __pyx_v_df, __pyx_v_columns); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_249_validate_columns(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_df, PyObject *__pyx_v_columns) { PyObject *__pyx_v_xname = NULL; PyObject *__pyx_v_yname = NULL; PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__296) __Pyx_TraceCall("_validate_columns", __pyx_f[0], 7846, 0, __PYX_ERR(0, 7846, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils._validate_columns", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_xname); __Pyx_XDECREF(__pyx_v_yname); __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__528 = PyTuple_Pack(7, __pyx_n_s_df, __pyx_n_s_columns, __pyx_n_s_xname, __pyx_n_s_yname, __pyx_n_s_x, __pyx_n_s_y_4, __pyx_n_s_e); if (unlikely(!__pyx_tuple__528)) __PYX_ERR(0, 7846, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__528); __Pyx_GIVEREF(__pyx_tuple__528); /* … */ __Pyx_TraceLine(7846,0,__PYX_ERR(0, 7846, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_250_validate_columns, 0, __pyx_n_s_validate_columns, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__296)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7846, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_columns, __pyx_t_5) < 0) __PYX_ERR(0, 7846, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__296 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__528, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_columns, 7846, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__296)) __PYX_ERR(0, 7846, __pyx_L1_error)
7847: """
7848: Validates and extracts x, y coordinates from a DataFrame based on column
7849: names or indices.
7850:
7851: Parameters
7852: ----------
7853: df : pandas.DataFrame
7854: The DataFrame from which to extract coordinate columns.
7855: columns : list of str or int
7856: The names or indices of the columns to extract as coordinates.
7857:
7858: Returns
7859: -------
7860: x, xname, y, yname : (pandas.Series, str/int, pandas.Series, str/int)
7861: The extracted x and y coordinate Series along with their column
7862: names or indices.
7863:
7864: Raises
7865: ------
7866: ValueError
7867: If the specified columns are not found in the DataFrame or if the
7868: columns list is not correctly specified.
7869: """
+7870: if not isinstance(columns, (list, tuple)) or len(columns) < 2:
__Pyx_TraceLine(7870,0,__PYX_ERR(0, 7870, __pyx_L1_error)) __pyx_t_3 = PyList_Check(__pyx_v_columns); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L6_bool_binop_done; } __pyx_t_3 = PyTuple_Check(__pyx_v_columns); __pyx_t_2 = __pyx_t_3; __pyx_L6_bool_binop_done:; __pyx_t_3 = (!__pyx_t_2); if (!__pyx_t_3) { } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_4 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 7870, __pyx_L1_error) __pyx_t_3 = (__pyx_t_4 < 2); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+7871: raise ValueError("Columns parameter must be a list or tuple with at"
__Pyx_TraceLine(7871,0,__PYX_ERR(0, 7871, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__297, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7871, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 7871, __pyx_L1_error) /* … */ __pyx_tuple__297 = PyTuple_Pack(1, __pyx_kp_u_Columns_parameter_must_be_a_list_2); if (unlikely(!__pyx_tuple__297)) __PYX_ERR(0, 7871, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__297); __Pyx_GIVEREF(__pyx_tuple__297);
7872: " least two elements.")
7873:
+7874: try:
__Pyx_TraceLine(7874,0,__PYX_ERR(0, 7874, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L13_try_end; __pyx_L8_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L10_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L13_try_end:; }
+7875: xname, yname = columns[0], columns[1]
__Pyx_TraceLine(7875,0,__PYX_ERR(0, 7875, __pyx_L8_error)) __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_columns, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7875, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_columns, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 7875, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); __pyx_v_xname = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_yname = __pyx_t_9; __pyx_t_9 = 0;
+7876: x = df[xname] if isinstance(xname, str) else df.iloc[:, xname]
__Pyx_TraceLine(7876,0,__PYX_ERR(0, 7876, __pyx_L8_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_xname); if (__pyx_t_1) { __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_df, __pyx_v_xname); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7876, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __pyx_t_5; __pyx_t_5 = 0; } else { __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_iloc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7876, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7876, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__130)) __PYX_ERR(0, 7876, __pyx_L8_error); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_xname)) __PYX_ERR(0, 7876, __pyx_L8_error); __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7876, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_9 = __pyx_t_11; __pyx_t_11 = 0; } __pyx_v_x = __pyx_t_9; __pyx_t_9 = 0;
+7877: y = df[yname] if isinstance(yname, str) else df.iloc[:, yname]
__Pyx_TraceLine(7877,0,__PYX_ERR(0, 7877, __pyx_L8_error)) __pyx_t_1 = PyUnicode_Check(__pyx_v_yname); if (__pyx_t_1) { __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_v_df, __pyx_v_yname); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7877, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_9 = __pyx_t_11; __pyx_t_11 = 0; } else { __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_df, __pyx_n_s_iloc); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7877, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7877, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__130)) __PYX_ERR(0, 7877, __pyx_L8_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_yname)) __PYX_ERR(0, 7877, __pyx_L8_error); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7877, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_9 = __pyx_t_5; __pyx_t_5 = 0; } __pyx_v_y = __pyx_t_9; __pyx_t_9 = 0;
+7878: except Exception as e:
__Pyx_TraceLine(7878,0,__PYX_ERR(0, 7878, __pyx_L10_except_error)) __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_12) { __Pyx_AddTraceback("gofast.tools.coreutils._validate_columns", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 7878, __pyx_L10_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_t_5); __pyx_v_e = __pyx_t_5; /*try:*/ { /* … */ __Pyx_TraceLine(7878,0,__PYX_ERR(0, 7878, __pyx_L19_error)) /*finally:*/ { __pyx_L19_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_12 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15; goto __pyx_L10_except_error; } } } goto __pyx_L10_except_error;
+7879: raise ValueError(f"Error extracting columns: {e}")
__Pyx_TraceLine(7879,0,__PYX_ERR(0, 7879, __pyx_L19_error)) __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7879, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Error_extracting_columns, __pyx_t_11); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 7879, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 7879, __pyx_L19_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 7879, __pyx_L19_error) }
7880:
+7881: return x, xname, y, yname
__Pyx_TraceLine(7881,0,__PYX_ERR(0, 7881, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 7881, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_x)) __PYX_ERR(0, 7881, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_xname)) __PYX_ERR(0, 7881, __pyx_L1_error); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_v_y)) __PYX_ERR(0, 7881, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_v_yname)) __PYX_ERR(0, 7881, __pyx_L1_error); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0;
7882:
+7883: def _process_dataset(dataset, columns):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_252_process_dataset(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_251_process_dataset, "\n Processes the dataset (X or Xt) to extract 'x' and 'y' coordinates based \n on provided column names or indices.\n \n Parameters\n ----------\n dataset : pandas.DataFrame or numpy.ndarray\n The dataset from which to extract 'x' and 'y' coordinates.\n columns : list of str or int\n The names or indices of the columns to extract as coordinates. \n For ndarray, integers are expected.\n \n Returns\n -------\n x, y, xname, yname : (numpy.array or pandas.Series, numpy.array or \n pandas.Series, str/int, str/int)\n The extracted 'x' and 'y' coordinates, along with their column names \n or indices.\n \n Raises\n ------\n ValueError\n If the dataset or columns are not properly specified.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_252_process_dataset = {"_process_dataset", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_252_process_dataset, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_251_process_dataset}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_252_process_dataset(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_dataset = 0; PyObject *__pyx_v_columns = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_process_dataset (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dataset,&__pyx_n_s_columns,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dataset)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7883, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_columns)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7883, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_process_dataset", 1, 2, 2, 1); __PYX_ERR(0, 7883, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_process_dataset") < 0)) __PYX_ERR(0, 7883, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_dataset = values[0]; __pyx_v_columns = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_process_dataset", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 7883, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._process_dataset", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_251_process_dataset(__pyx_self, __pyx_v_dataset, __pyx_v_columns); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_251_process_dataset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dataset, PyObject *__pyx_v_columns) { PyObject *__pyx_v_x = NULL; PyObject *__pyx_v_xname = NULL; PyObject *__pyx_v_y = NULL; PyObject *__pyx_v_yname = NULL; PyObject *__pyx_v_xindex = NULL; PyObject *__pyx_v_yindex = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__298) __Pyx_TraceCall("_process_dataset", __pyx_f[0], 7883, 0, __PYX_ERR(0, 7883, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils._process_dataset", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_x); __Pyx_XDECREF(__pyx_v_xname); __Pyx_XDECREF(__pyx_v_y); __Pyx_XDECREF(__pyx_v_yname); __Pyx_XDECREF(__pyx_v_xindex); __Pyx_XDECREF(__pyx_v_yindex); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__529 = PyTuple_Pack(8, __pyx_n_s_dataset, __pyx_n_s_columns, __pyx_n_s_x, __pyx_n_s_xname, __pyx_n_s_y_4, __pyx_n_s_yname, __pyx_n_s_xindex, __pyx_n_s_yindex); if (unlikely(!__pyx_tuple__529)) __PYX_ERR(0, 7883, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__529); __Pyx_GIVEREF(__pyx_tuple__529); /* … */ __Pyx_TraceLine(7883,0,__PYX_ERR(0, 7883, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_252_process_dataset, 0, __pyx_n_s_process_dataset, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__298)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_d, __pyx_n_s_process_dataset, __pyx_t_5) < 0) __PYX_ERR(0, 7883, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__298 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__529, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_process_dataset, 7883, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__298)) __PYX_ERR(0, 7883, __pyx_L1_error)
7884: """
7885: Processes the dataset (X or Xt) to extract 'x' and 'y' coordinates based
7886: on provided column names or indices.
7887:
7888: Parameters
7889: ----------
7890: dataset : pandas.DataFrame or numpy.ndarray
7891: The dataset from which to extract 'x' and 'y' coordinates.
7892: columns : list of str or int
7893: The names or indices of the columns to extract as coordinates.
7894: For ndarray, integers are expected.
7895:
7896: Returns
7897: -------
7898: x, y, xname, yname : (numpy.array or pandas.Series, numpy.array or
7899: pandas.Series, str/int, str/int)
7900: The extracted 'x' and 'y' coordinates, along with their column names
7901: or indices.
7902:
7903: Raises
7904: ------
7905: ValueError
7906: If the dataset or columns are not properly specified.
7907: """
+7908: if isinstance(dataset, pd.DataFrame):
__Pyx_TraceLine(7908,0,__PYX_ERR(0, 7908, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_dataset, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 7908, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+7909: x, xname, y, yname = _validate_columns(dataset, columns)
__Pyx_TraceLine(7909,0,__PYX_ERR(0, 7909, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_validate_columns); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_dataset, __pyx_v_columns}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { PyObject* sequence = __pyx_t_2; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 7909, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); } else { __pyx_t_1 = PyList_GET_ITEM(sequence, 0); __pyx_t_4 = PyList_GET_ITEM(sequence, 1); __pyx_t_6 = PyList_GET_ITEM(sequence, 2); __pyx_t_7 = PyList_GET_ITEM(sequence, 3); } __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_6,&__pyx_t_7}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 7909, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_6,&__pyx_t_7}; __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7909, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); for (index=0; index < 4; index++) { PyObject* item = __pyx_t_9(__pyx_t_8); if (unlikely(!item)) goto __pyx_L4_unpacking_failed; __Pyx_GOTREF(item); *(temps[index]) = item; } if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) __PYX_ERR(0, 7909, __pyx_L1_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L5_unpacking_done; __pyx_L4_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 7909, __pyx_L1_error) __pyx_L5_unpacking_done:; } __pyx_v_x = __pyx_t_1; __pyx_t_1 = 0; __pyx_v_xname = __pyx_t_4; __pyx_t_4 = 0; __pyx_v_y = __pyx_t_6; __pyx_t_6 = 0; __pyx_v_yname = __pyx_t_7; __pyx_t_7 = 0;
+7910: return x.to_numpy(), y.to_numpy(), xname, yname
__Pyx_TraceLine(7910,0,__PYX_ERR(0, 7910, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_n_s_to_numpy); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_7))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_y, __pyx_n_s_to_numpy); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2)) __PYX_ERR(0, 7910, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_7); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7)) __PYX_ERR(0, 7910, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xname); __Pyx_GIVEREF(__pyx_v_xname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_v_xname)) __PYX_ERR(0, 7910, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yname); __Pyx_GIVEREF(__pyx_v_yname); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_yname)) __PYX_ERR(0, 7910, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_7 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+7911: elif isinstance(dataset, np.ndarray):
__Pyx_TraceLine(7911,0,__PYX_ERR(0, 7911, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7911, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7911, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_dataset, __pyx_t_7); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 7911, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (likely(__pyx_t_3)) { /* … */ }
+7912: if not isinstance(columns, (list, tuple)) or len(columns) < 2:
__Pyx_TraceLine(7912,0,__PYX_ERR(0, 7912, __pyx_L1_error)) __pyx_t_11 = PyList_Check(__pyx_v_columns); if (!__pyx_t_11) { } else { __pyx_t_10 = __pyx_t_11; goto __pyx_L9_bool_binop_done; } __pyx_t_11 = PyTuple_Check(__pyx_v_columns); __pyx_t_10 = __pyx_t_11; __pyx_L9_bool_binop_done:; __pyx_t_11 = (!__pyx_t_10); if (!__pyx_t_11) { } else { __pyx_t_3 = __pyx_t_11; goto __pyx_L7_bool_binop_done; } __pyx_t_12 = PyObject_Length(__pyx_v_columns); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 7912, __pyx_L1_error) __pyx_t_11 = (__pyx_t_12 < 2); __pyx_t_3 = __pyx_t_11; __pyx_L7_bool_binop_done:; if (unlikely(__pyx_t_3)) { /* … */ }
+7913: raise ValueError("For ndarray, columns must be a list or tuple "
__Pyx_TraceLine(7913,0,__PYX_ERR(0, 7913, __pyx_L1_error)) __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__299, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7913, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 7913, __pyx_L1_error) /* … */ __pyx_tuple__299 = PyTuple_Pack(1, __pyx_kp_u_For_ndarray_columns_must_be_a_li); if (unlikely(!__pyx_tuple__299)) __PYX_ERR(0, 7913, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__299); __Pyx_GIVEREF(__pyx_tuple__299);
7914: "with at least two indices.")
+7915: xindex, yindex = columns[0], columns[1]
__Pyx_TraceLine(7915,0,__PYX_ERR(0, 7915, __pyx_L1_error)) __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_columns, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_columns, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7915, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_xindex = __pyx_t_7; __pyx_t_7 = 0; __pyx_v_yindex = __pyx_t_6; __pyx_t_6 = 0;
+7916: x, y = dataset[:, xindex], dataset[:, yindex]
__Pyx_TraceLine(7916,0,__PYX_ERR(0, 7916, __pyx_L1_error)) __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__130)) __PYX_ERR(0, 7916, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xindex); __Pyx_GIVEREF(__pyx_v_xindex); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_xindex)) __PYX_ERR(0, 7916, __pyx_L1_error); __pyx_t_7 = __Pyx_PyObject_GetItem(__pyx_v_dataset, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 7916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__130)) __PYX_ERR(0, 7916, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yindex); __Pyx_GIVEREF(__pyx_v_yindex); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_yindex)) __PYX_ERR(0, 7916, __pyx_L1_error); __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_dataset, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_x = __pyx_t_7; __pyx_t_7 = 0; __pyx_v_y = __pyx_t_2; __pyx_t_2 = 0;
+7917: return x, y, xindex, yindex
__Pyx_TraceLine(7917,0,__PYX_ERR(0, 7917, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7917, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x)) __PYX_ERR(0, 7917, __pyx_L1_error); __Pyx_INCREF(__pyx_v_y); __Pyx_GIVEREF(__pyx_v_y); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_y)) __PYX_ERR(0, 7917, __pyx_L1_error); __Pyx_INCREF(__pyx_v_xindex); __Pyx_GIVEREF(__pyx_v_xindex); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_xindex)) __PYX_ERR(0, 7917, __pyx_L1_error); __Pyx_INCREF(__pyx_v_yindex); __Pyx_GIVEREF(__pyx_v_yindex); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_yindex)) __PYX_ERR(0, 7917, __pyx_L1_error); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
7918: else:
+7919: raise ValueError("Dataset must be a pandas.DataFrame or numpy.ndarray.")
__Pyx_TraceLine(7919,0,__PYX_ERR(0, 7919, __pyx_L1_error)) /*else*/ { __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__300, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7919, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 7919, __pyx_L1_error) } /* … */ __pyx_tuple__300 = PyTuple_Pack(1, __pyx_kp_u_Dataset_must_be_a_pandas_DataFra); if (unlikely(!__pyx_tuple__300)) __PYX_ERR(0, 7919, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__300); __Pyx_GIVEREF(__pyx_tuple__300);
7920:
+7921: def validate_feature(data: Union[DataFrame, Series], features: List[str],
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_254validate_feature(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_253validate_feature, "\n Validate the existence of specified features in a DataFrame or Series.\n\n Parameters\n ----------\n data : DataFrame or Series\n The DataFrame or Series to validate feature existence.\n features : list of str\n List of features to check for existence in the data.\n verbose : str, {'raise', 'ignore'}, optional\n Specify how to handle the absence of features. 'raise' (default) will raise\n a ValueError if any feature is missing, while 'ignore' will return a\n boolean indicating whether all features exist.\n\n Returns\n -------\n bool\n True if all specified features exist in the data, False otherwise.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import validate_feature\n >>> import pandas as pd\n >>> data = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})\n >>> result = validate_feature(data, ['A', 'C'], verbose='raise')\n >>> print(result) # This will raise a ValueError\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_254validate_feature = {"validate_feature", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_254validate_feature, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_253validate_feature}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_254validate_feature(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_features = 0; PyObject *__pyx_v_verbose = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("validate_feature (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_features,&__pyx_n_s_verbose,0}; PyObject* values[3] = {0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_raise))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7921, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_features)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7921, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("validate_feature", 0, 2, 3, 1); __PYX_ERR(0, 7921, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7921, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "validate_feature") < 0)) __PYX_ERR(0, 7921, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_features = values[1]; __pyx_v_verbose = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("validate_feature", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 7921, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.validate_feature", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_verbose), (&PyUnicode_Type), 0, "verbose", 1))) __PYX_ERR(0, 7922, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_253validate_feature(__pyx_self, __pyx_v_data, __pyx_v_features, __pyx_v_verbose); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_253validate_feature(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_features, PyObject *__pyx_v_verbose) { PyObject *__pyx_v_present_features = NULL; PyObject *__pyx_v_missing_features = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__301) __Pyx_TraceCall("validate_feature", __pyx_f[0], 7921, 0, __PYX_ERR(0, 7921, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_data); __Pyx_INCREF(__pyx_v_features); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.validate_feature", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_present_features); __Pyx_XDECREF(__pyx_v_missing_features); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_features); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__530 = PyTuple_Pack(5, __pyx_n_s_data, __pyx_n_s_features, __pyx_n_s_verbose, __pyx_n_s_present_features, __pyx_n_s_missing_features); if (unlikely(!__pyx_tuple__530)) __PYX_ERR(0, 7921, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__530); __Pyx_GIVEREF(__pyx_tuple__530); __pyx_codeobj__301 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__530, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_validate_feature, 7921, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__301)) __PYX_ERR(0, 7921, __pyx_L1_error) /* … */ __Pyx_TraceLine(7921,0,__PYX_ERR(0, 7921, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7921, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_kp_s_Union_DataFrame_Series) < 0) __PYX_ERR(0, 7921, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_features, __pyx_kp_s_List_str) < 0) __PYX_ERR(0, 7921, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_verbose, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7921, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 7921, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_254validate_feature, 0, __pyx_n_s_validate_feature, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__301)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7921, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__531); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_validate_feature, __pyx_t_8) < 0) __PYX_ERR(0, 7921, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__531 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_raise)); if (unlikely(!__pyx_tuple__531)) __PYX_ERR(0, 7921, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__531); __Pyx_GIVEREF(__pyx_tuple__531);
7922: verbose: str = 'raise') -> bool:
7923: """
7924: Validate the existence of specified features in a DataFrame or Series.
7925:
7926: Parameters
7927: ----------
7928: data : DataFrame or Series
7929: The DataFrame or Series to validate feature existence.
7930: features : list of str
7931: List of features to check for existence in the data.
7932: verbose : str, {'raise', 'ignore'}, optional
7933: Specify how to handle the absence of features. 'raise' (default) will raise
7934: a ValueError if any feature is missing, while 'ignore' will return a
7935: boolean indicating whether all features exist.
7936:
7937: Returns
7938: -------
7939: bool
7940: True if all specified features exist in the data, False otherwise.
7941:
7942: Examples
7943: --------
7944: >>> from gofast.tools.coreutils import validate_feature
7945: >>> import pandas as pd
7946: >>> data = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
7947: >>> result = validate_feature(data, ['A', 'C'], verbose='raise')
7948: >>> print(result) # This will raise a ValueError
7949: """
+7950: if isinstance(data, pd.Series):
__Pyx_TraceLine(7950,0,__PYX_ERR(0, 7950, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7950, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_data, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 7950, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { /* … */ }
+7951: data = data.to_frame().T # Convert Series to DataFrame
__Pyx_TraceLine(7951,0,__PYX_ERR(0, 7951, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_to_frame); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_1))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_T); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7951, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_1); __pyx_t_1 = 0;
+7952: features= is_iterable(features, exclude_string= True, transform =True )
__Pyx_TraceLine(7952,0,__PYX_ERR(0, 7952, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_features); __Pyx_GIVEREF(__pyx_v_features); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_features)) __PYX_ERR(0, 7952, __pyx_L1_error); __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 7952, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 7952, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7952, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF_SET(__pyx_v_features, __pyx_t_6); __pyx_t_6 = 0;
+7953: present_features = set(features).intersection(data.columns)
__Pyx_TraceLine(7953,0,__PYX_ERR(0, 7953, __pyx_L1_error)) __pyx_t_4 = PySet_New(__pyx_v_features); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_intersection); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_4}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7953, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_present_features = __pyx_t_6; __pyx_t_6 = 0;
7954:
+7955: if len(present_features) != len(features):
__Pyx_TraceLine(7955,0,__PYX_ERR(0, 7955, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_present_features); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 7955, __pyx_L1_error) __pyx_t_8 = PyObject_Length(__pyx_v_features); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 7955, __pyx_L1_error) __pyx_t_3 = (__pyx_t_7 != __pyx_t_8); if (__pyx_t_3) { /* … */ }
+7956: missing_features = set(features).difference(present_features)
__Pyx_TraceLine(7956,0,__PYX_ERR(0, 7956, __pyx_L1_error)) __pyx_t_2 = PySet_New(__pyx_v_features); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_difference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_present_features}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7956, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_missing_features = __pyx_t_6; __pyx_t_6 = 0;
+7957: if verbose == 'raise':
__Pyx_TraceLine(7957,0,__PYX_ERR(0, 7957, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_verbose, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 7957, __pyx_L1_error) if (unlikely(__pyx_t_3)) { /* … */ }
+7958: raise ValueError("The following features are missing in the "
__Pyx_TraceLine(7958,0,__PYX_ERR(0, 7958, __pyx_L1_error)) __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = 0; __pyx_t_9 = 127; __Pyx_INCREF(__pyx_kp_u_The_following_features_are_missi); __pyx_t_8 += 48; __Pyx_GIVEREF(__pyx_kp_u_The_following_features_are_missi); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_The_following_features_are_missi); /* … */ __Pyx_TraceLine(7958,0,__PYX_ERR(0, 7958, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_6, 3, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 7958, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 7958, __pyx_L1_error)
+7959: f"data: {smart_format(missing_features)}.")
__Pyx_TraceLine(7959,0,__PYX_ERR(0, 7959, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_smart_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_missing_features}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 7959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7959, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2) : __pyx_t_9; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2); __pyx_t_2 = 0; __Pyx_INCREF(__pyx_kp_u__26); __pyx_t_8 += 1; __Pyx_GIVEREF(__pyx_kp_u__26); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u__26);
+7960: return False
__Pyx_TraceLine(7960,0,__PYX_ERR(0, 7960, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
7961:
+7962: return True
__Pyx_TraceLine(7962,0,__PYX_ERR(0, 7962, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
7963:
+7964: def features_in(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_256features_in(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_255features_in, "\n Control whether the specified features exist in multiple datasets.\n\n Parameters\n ----------\n *data : DataFrame or Series arguments\n Multiple DataFrames or Series to check for feature existence.\n features : list of str\n List of features to check for existence in the datasets.\n error : str, {'raise', 'ignore'}, optional\n Specify how to handle the absence of features. 'ignore' (default) will ignore\n a ValueError for each dataset with missing features, while 'ignore' will\n return a list of booleans indicating whether all features exist in each dataset.\n\n Returns\n -------\n list of bool\n A list of booleans indicating whether the specified features exist in each dataset.\n\n Examples\n --------\n >>> import pandas as pd\n >>> from gofast.tools.coreutils import features_in\n >>> data1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})\n >>> data2 = pd.Series([5, 6], name='C')\n >>> data3 = pd.DataFrame({'X': [7, 8]})\n >>> features = ['A', 'C']\n >>> results1 = features_in(data1, data2, features, error='raise')\n >>> print(results1) # This will raise a ValueError for the first dataset\n >>> results2 = features_in(data1, data3, features, error='ignore')\n >>> print(results2) # This will return [True, False]\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_256features_in = {"features_in", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_256features_in, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_255features_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_256features_in(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_features = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_data = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("features_in (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_data = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_features,&__pyx_n_s_error,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)((PyObject*)__pyx_n_u_ignore))); if (likely(__pyx_kwds)) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_features)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7964, __pyx_L3_error) else { __Pyx_RaiseKeywordRequired("features_in", __pyx_n_s_features); __PYX_ERR(0, 7964, __pyx_L3_error) } if (kw_args == 1) { const Py_ssize_t index = 1; PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 7964, __pyx_L3_error) } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "features_in") < 0)) __PYX_ERR(0, 7964, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { __Pyx_RaiseKeywordRequired("features_in", __pyx_n_s_features); __PYX_ERR(0, 7964, __pyx_L3_error) } __pyx_v_features = values[0]; __pyx_v_error = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("features_in", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 7964, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_data); __pyx_v_data = 0; __Pyx_AddTraceback("gofast.tools.coreutils.features_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_error), (&PyUnicode_Type), 0, "error", 1))) __PYX_ERR(0, 7966, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_255features_in(__pyx_self, __pyx_v_features, __pyx_v_error, __pyx_v_data); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_data); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_255features_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_features, PyObject *__pyx_v_error, PyObject *__pyx_v_data) { PyObject *__pyx_v_results = NULL; PyObject *__pyx_v_dataset = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__302) __Pyx_TraceCall("features_in", __pyx_f[0], 7964, 0, __PYX_ERR(0, 7964, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.features_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_results); __Pyx_XDECREF(__pyx_v_dataset); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__532 = PyTuple_Pack(5, __pyx_n_s_features, __pyx_n_s_error, __pyx_n_s_data, __pyx_n_s_results, __pyx_n_s_dataset); if (unlikely(!__pyx_tuple__532)) __PYX_ERR(0, 7964, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__532); __Pyx_GIVEREF(__pyx_tuple__532); /* … */ __Pyx_TraceLine(7964,0,__PYX_ERR(0, 7964, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 7964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_error, ((PyObject*)__pyx_n_u_ignore)) < 0) __PYX_ERR(0, 7964, __pyx_L1_error) __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 7964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_features, __pyx_kp_s_List_str) < 0) __PYX_ERR(0, 7964, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_error, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 7964, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_kp_s_Union_pd_DataFrame_pd_Series) < 0) __PYX_ERR(0, 7964, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_List_bool) < 0) __PYX_ERR(0, 7964, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_256features_in, 0, __pyx_n_s_features_in, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__302)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7964, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_features_in, __pyx_t_2) < 0) __PYX_ERR(0, 7964, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__302 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__532, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_features_in, 7964, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__302)) __PYX_ERR(0, 7964, __pyx_L1_error)
7965: *data: Union[pd.DataFrame, pd.Series], features: List[str],
7966: error: str = 'ignore') -> List[bool]:
7967: """
7968: Control whether the specified features exist in multiple datasets.
7969:
7970: Parameters
7971: ----------
7972: *data : DataFrame or Series arguments
7973: Multiple DataFrames or Series to check for feature existence.
7974: features : list of str
7975: List of features to check for existence in the datasets.
7976: error : str, {'raise', 'ignore'}, optional
7977: Specify how to handle the absence of features. 'ignore' (default) will ignore
7978: a ValueError for each dataset with missing features, while 'ignore' will
7979: return a list of booleans indicating whether all features exist in each dataset.
7980:
7981: Returns
7982: -------
7983: list of bool
7984: A list of booleans indicating whether the specified features exist in each dataset.
7985:
7986: Examples
7987: --------
7988: >>> import pandas as pd
7989: >>> from gofast.tools.coreutils import features_in
7990: >>> data1 = pd.DataFrame({'A': [1, 2], 'B': [3, 4]})
7991: >>> data2 = pd.Series([5, 6], name='C')
7992: >>> data3 = pd.DataFrame({'X': [7, 8]})
7993: >>> features = ['A', 'C']
7994: >>> results1 = features_in(data1, data2, features, error='raise')
7995: >>> print(results1) # This will raise a ValueError for the first dataset
7996: >>> results2 = features_in(data1, data3, features, error='ignore')
7997: >>> print(results2) # This will return [True, False]
7998: """
+7999: results = []
__Pyx_TraceLine(7999,0,__PYX_ERR(0, 7999, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7999, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_results = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
8000:
+8001: for dataset in data:
__Pyx_TraceLine(8001,0,__PYX_ERR(0, 8001, __pyx_L1_error)) __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8001, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 8001, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8001, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_dataset, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(8001,0,__PYX_ERR(0, 8001, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+8002: results.append(validate_feature(dataset, features, verbose=error))
__Pyx_TraceLine(8002,0,__PYX_ERR(0, 8002, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_validate_feature); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_dataset); __Pyx_GIVEREF(__pyx_v_dataset); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_dataset)) __PYX_ERR(0, 8002, __pyx_L1_error); __Pyx_INCREF(__pyx_v_features); __Pyx_GIVEREF(__pyx_v_features); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_features)) __PYX_ERR(0, 8002, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_verbose, __pyx_v_error) < 0) __PYX_ERR(0, 8002, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8002, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_7 = __Pyx_PyList_Append(__pyx_v_results, __pyx_t_6); if (unlikely(__pyx_t_7 == ((int)-1))) __PYX_ERR(0, 8002, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8003:
+8004: return results
__Pyx_TraceLine(8004,0,__PYX_ERR(0, 8004, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_results); __pyx_r = __pyx_v_results; goto __pyx_L0;
8005:
+8006: def find_features_in(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_258find_features_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_257find_features_in, "\n Retrieve the categorical or numerical features from the dataset.\n\n Parameters\n ----------\n data : DataFrame, optional\n DataFrame with columns representing the features.\n features : list of str, optional\n List of column names. If provided, the DataFrame will be restricted\n to only include the specified features before searching for numerical\n and categorical features. An error will be raised if any specified\n feature is missing in the DataFrame.\n return_frames : bool, optional\n If True, it returns two separate DataFrames (cat & num). Otherwise, it\n returns only the column names of categorical and numerical features.\n parse_features : bool, default False\n Use default parsers to parse string items into an iterable object.\n\n Returns\n -------\n Tuple : List[str] or DataFrame\n The names or DataFrames of categorical and numerical features.\n\n Examples\n --------\n >>> from gofast.datasets import fetch_data\n >>> from gofast.tools.mlutils import find_features_in\n >>> data = fetch_data('bagoue').frame \n >>> cat, num = find_features_in(data)\n >>> cat, num\n ... (['type', 'geol', 'shape', 'name', 'flow'],\n ... ['num', 'east', 'north', 'power', 'magnitude', 'sfi', 'ohmS', 'lwi'])\n >>> cat, num = find_features_in(data, features=['geol', 'ohmS', 'sfi'])\n >>> cat, num\n ... (['geol'], ['ohmS', 'sfi'])\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_258find_features_in = {"find_features_in", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_258find_features_in, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_257find_features_in}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_258find_features_in(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; PyObject *__pyx_v_features = 0; PyObject *__pyx_v_parse_features = 0; PyObject *__pyx_v_return_frames = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("find_features_in (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_features,&__pyx_n_s_parse_features,&__pyx_n_s_return_frames,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_257find_features_in(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, PyObject *__pyx_v_features, PyObject *__pyx_v_parse_features, PyObject *__pyx_v_return_frames) { PyObject *__pyx_v_numnames = NULL; PyObject *__pyx_v_catnames = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__303) __Pyx_TraceCall("find_features_in", __pyx_f[0], 8006, 0, __PYX_ERR(0, 8006, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_data); __Pyx_INCREF(__pyx_v_features); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.find_features_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_numnames); __Pyx_XDECREF(__pyx_v_catnames); __Pyx_XDECREF(__pyx_v_data); __Pyx_XDECREF(__pyx_v_features); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__533 = PyTuple_Pack(6, __pyx_n_s_data, __pyx_n_s_features, __pyx_n_s_parse_features, __pyx_n_s_return_frames, __pyx_n_s_numnames, __pyx_n_s_catnames); if (unlikely(!__pyx_tuple__533)) __PYX_ERR(0, 8006, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__533); __Pyx_GIVEREF(__pyx_tuple__533); __pyx_codeobj__303 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__533, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_find_features_in, 8006, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__303)) __PYX_ERR(0, 8006, __pyx_L1_error) /* … */ __Pyx_TraceLine(8006,0,__PYX_ERR(0, 8006, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_data, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 8006, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_features, __pyx_kp_s_List_str) < 0) __PYX_ERR(0, 8006, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_parse_features, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8006, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return_frames, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8006, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Tuple_Union_List_str_DataFrame_U) < 0) __PYX_ERR(0, 8006, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_258find_features_in, 0, __pyx_n_s_find_features_in, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__303)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8006, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__534); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_find_features_in, __pyx_t_5) < 0) __PYX_ERR(0, 8006, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__534 = PyTuple_Pack(4, Py_None, Py_None, ((PyObject *)Py_False), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__534)) __PYX_ERR(0, 8006, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__534); __Pyx_GIVEREF(__pyx_tuple__534);
+8007: data: DataFrame = None,
values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+8008: features: List[str] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+8009: parse_features: bool = False,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+8010: return_frames: bool = False,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8006, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_features); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8006, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_parse_features); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8006, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_frames); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8006, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "find_features_in") < 0)) __PYX_ERR(0, 8006, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_features = values[1]; __pyx_v_parse_features = values[2]; __pyx_v_return_frames = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("find_features_in", 0, 0, 4, __pyx_nargs); __PYX_ERR(0, 8006, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.find_features_in", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_257find_features_in(__pyx_self, __pyx_v_data, __pyx_v_features, __pyx_v_parse_features, __pyx_v_return_frames);
8011: ) -> Tuple[Union[List[str], DataFrame], Union[List[str], DataFrame]]:
8012: """
8013: Retrieve the categorical or numerical features from the dataset.
8014:
8015: Parameters
8016: ----------
8017: data : DataFrame, optional
8018: DataFrame with columns representing the features.
8019: features : list of str, optional
8020: List of column names. If provided, the DataFrame will be restricted
8021: to only include the specified features before searching for numerical
8022: and categorical features. An error will be raised if any specified
8023: feature is missing in the DataFrame.
8024: return_frames : bool, optional
8025: If True, it returns two separate DataFrames (cat & num). Otherwise, it
8026: returns only the column names of categorical and numerical features.
8027: parse_features : bool, default False
8028: Use default parsers to parse string items into an iterable object.
8029:
8030: Returns
8031: -------
8032: Tuple : List[str] or DataFrame
8033: The names or DataFrames of categorical and numerical features.
8034:
8035: Examples
8036: --------
8037: >>> from gofast.datasets import fetch_data
8038: >>> from gofast.tools.mlutils import find_features_in
8039: >>> data = fetch_data('bagoue').frame
8040: >>> cat, num = find_features_in(data)
8041: >>> cat, num
8042: ... (['type', 'geol', 'shape', 'name', 'flow'],
8043: ... ['num', 'east', 'north', 'power', 'magnitude', 'sfi', 'ohmS', 'lwi'])
8044: >>> cat, num = find_features_in(data, features=['geol', 'ohmS', 'sfi'])
8045: >>> cat, num
8046: ... (['geol'], ['ohmS', 'sfi'])
8047: """
+8048: if not isinstance (data, pd.DataFrame):
__Pyx_TraceLine(8048,0,__PYX_ERR(0, 8048, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8048, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8048, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = PyObject_IsInstance(__pyx_v_data, __pyx_t_2); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 8048, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (!__pyx_t_3); if (unlikely(__pyx_t_4)) { /* … */ }
+8049: raise TypeError(f"Expect a DataFrame. Got {type(data).__name__!r}")
__Pyx_TraceLine(8049,0,__PYX_ERR(0, 8049, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_n_s_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_t_2), __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Expect_a_DataFrame_Got, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8049, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 8049, __pyx_L1_error)
8050:
+8051: if features is not None:
__Pyx_TraceLine(8051,0,__PYX_ERR(0, 8051, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_features != Py_None); if (__pyx_t_4) { /* … */ }
+8052: features = list(
__Pyx_TraceLine(8052,0,__PYX_ERR(0, 8052, __pyx_L1_error)) __pyx_t_5 = __Pyx_PySequence_ListKeepNew(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8052, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF_SET(__pyx_v_features, __pyx_t_5); __pyx_t_5 = 0;
+8053: is_iterable(
__Pyx_TraceLine(8053,0,__PYX_ERR(0, 8053, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(8054,0,__PYX_ERR(0, 8054, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_features); __Pyx_GIVEREF(__pyx_v_features); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_features)) __PYX_ERR(0, 8053, __pyx_L1_error); /* … */ __Pyx_TraceLine(8053,0,__PYX_ERR(0, 8053, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8054: features,
+8055: exclude_string=True,
__Pyx_TraceLine(8055,0,__PYX_ERR(0, 8055, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8055, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 8055, __pyx_L1_error)
+8056: transform=True,
__Pyx_TraceLine(8056,0,__PYX_ERR(0, 8056, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 8055, __pyx_L1_error)
+8057: parse_string=parse_features,
__Pyx_TraceLine(8057,0,__PYX_ERR(0, 8057, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_parse_string, __pyx_v_parse_features) < 0) __PYX_ERR(0, 8055, __pyx_L1_error)
8058: )
8059: )
8060:
+8061: if features is None:
__Pyx_TraceLine(8061,0,__PYX_ERR(0, 8061, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_features == Py_None); if (__pyx_t_4) { /* … */ }
+8062: features = list(data.columns)
__Pyx_TraceLine(8062,0,__PYX_ERR(0, 8062, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_columns); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PySequence_ListKeepNew(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8062, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_features, __pyx_t_6); __pyx_t_6 = 0;
8063:
+8064: validate_feature(data, list(features))
__Pyx_TraceLine(8064,0,__PYX_ERR(0, 8064, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_validate_feature); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PySequence_List(__pyx_v_features); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_v_data, __pyx_t_2}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8064, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+8065: data = data[features].copy()
__Pyx_TraceLine(8065,0,__PYX_ERR(0, 8065, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_v_features); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_copy); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8065, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_6); __pyx_t_6 = 0;
8066:
8067: # Get numerical features
+8068: data, numnames, catnames = to_numeric_dtypes(data, return_feature_types=True )
__Pyx_TraceLine(8068,0,__PYX_ERR(0, 8068, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_to_numeric_dtypes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_data); __Pyx_GIVEREF(__pyx_v_data); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_data)) __PYX_ERR(0, 8068, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_feature_types, Py_True) < 0) __PYX_ERR(0, 8068, __pyx_L1_error) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { PyObject* sequence = __pyx_t_1; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 8068, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS if (likely(PyTuple_CheckExact(sequence))) { __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); } else { __pyx_t_5 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); __pyx_t_6 = PyList_GET_ITEM(sequence, 2); } __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); #else __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8068, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); index = 2; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 3) < 0) __PYX_ERR(0, 8068, __pyx_L1_error) __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L7_unpacking_done; __pyx_L6_unpacking_failed:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); __PYX_ERR(0, 8068, __pyx_L1_error) __pyx_L7_unpacking_done:; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_5); __pyx_t_5 = 0; __pyx_v_numnames = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_catnames = __pyx_t_6; __pyx_t_6 = 0;
8069:
+8070: if catnames is None:
__Pyx_TraceLine(8070,0,__PYX_ERR(0, 8070, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_catnames == Py_None); if (__pyx_t_4) { /* … */ }
+8071: catnames = []
__Pyx_TraceLine(8071,0,__PYX_ERR(0, 8071, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8071, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_catnames, __pyx_t_1); __pyx_t_1 = 0;
8072:
+8073: return (data[catnames], data[numnames]) if return_frames else (
__Pyx_TraceLine(8073,0,__PYX_ERR(0, 8073, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_return_frames); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 8073, __pyx_L1_error) if (__pyx_t_4) { __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_v_catnames); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_v_numnames); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8073, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_6); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6)) __PYX_ERR(0, 8073, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2)) __PYX_ERR(0, 8073, __pyx_L1_error); __pyx_t_6 = 0; __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_5; __pyx_t_5 = 0; } else {
+8074: list(catnames), list(numnames)
__Pyx_TraceLine(8074,0,__PYX_ERR(0, 8074, __pyx_L1_error)) __pyx_t_5 = PySequence_List(__pyx_v_catnames); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = PySequence_List(__pyx_v_numnames); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8074, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5)) __PYX_ERR(0, 8074, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2)) __PYX_ERR(0, 8074, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
8075: )
8076:
+8077: def split_train_test(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_260split_train_test(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_259split_train_test, "\n Split a DataFrame into train and test sets based on a given ratio.\n\n Parameters\n ----------\n data : DataFrame\n The DataFrame containing the features.\n test_ratio : float, optional\n The ratio of the test set, ranging from 0 to 1. Default is 0.2 (20%).\n\n Returns\n -------\n Tuple[DataFrame, DataFrame]\n A tuple of the train set and test set DataFrames.\n\n Examples\n --------\n >>> import pandas as pd\n >>> from sklearn.datasets import load_iris\n >>> from gofast.tools.coreutils import split_train_test\n >>> data = load_iris(as_frame=True)['data']\n >>> train_set, test_set = split_train_test(data, test_ratio=0.2)\n >>> len(train_set), len(test_set)\n ... (120, 30)\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_260split_train_test = {"split_train_test", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_260split_train_test, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_259split_train_test}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_260split_train_test(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; double __pyx_v_test_ratio; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("split_train_test (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_test_ratio,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8077, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_test_ratio); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8077, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "split_train_test") < 0)) __PYX_ERR(0, 8077, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; if (values[1]) { __pyx_v_test_ratio = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_test_ratio == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 8078, __pyx_L3_error) } else { __pyx_v_test_ratio = ((double)((double)0.2)); } } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("split_train_test", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 8077, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.split_train_test", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_259split_train_test(__pyx_self, __pyx_v_data, __pyx_v_test_ratio); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_259split_train_test(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, double __pyx_v_test_ratio) { PyObject *__pyx_v_shuffled_indices = NULL; PyObject *__pyx_v_test_set_size = NULL; PyObject *__pyx_v_test_indices = NULL; PyObject *__pyx_v_train_indices = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__304) __Pyx_TraceCall("split_train_test", __pyx_f[0], 8077, 0, __PYX_ERR(0, 8077, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.split_train_test", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_shuffled_indices); __Pyx_XDECREF(__pyx_v_test_set_size); __Pyx_XDECREF(__pyx_v_test_indices); __Pyx_XDECREF(__pyx_v_train_indices); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__535 = PyTuple_Pack(6, __pyx_n_s_data, __pyx_n_s_test_ratio, __pyx_n_s_shuffled_indices, __pyx_n_s_test_set_size, __pyx_n_s_test_indices, __pyx_n_s_train_indices); if (unlikely(!__pyx_tuple__535)) __PYX_ERR(0, 8077, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__535); __Pyx_GIVEREF(__pyx_tuple__535); /* … */ __Pyx_TraceLine(8077,0,__PYX_ERR(0, 8077, __pyx_L1_error)) __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_5); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5)) __PYX_ERR(0, 8077, __pyx_L1_error); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 8077, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_test_ratio, __pyx_n_s_float) < 0) __PYX_ERR(0, 8077, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_Tuple_DataFrame_DataFrame) < 0) __PYX_ERR(0, 8077, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_260split_train_test, 0, __pyx_n_s_split_train_test, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__304)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8077, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_t_2); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_train_test, __pyx_t_8) < 0) __PYX_ERR(0, 8077, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__304 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__535, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_split_train_test, 8077, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__304)) __PYX_ERR(0, 8077, __pyx_L1_error)
+8078: data: DataFrame, test_ratio: float = 0.2
__Pyx_TraceLine(8078,0,__PYX_ERR(0, 8078, __pyx_L1_error)) __pyx_t_5 = PyFloat_FromDouble(((double)0.2)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8078, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5);
8079: ) -> Tuple[DataFrame, DataFrame]:
8080: """
8081: Split a DataFrame into train and test sets based on a given ratio.
8082:
8083: Parameters
8084: ----------
8085: data : DataFrame
8086: The DataFrame containing the features.
8087: test_ratio : float, optional
8088: The ratio of the test set, ranging from 0 to 1. Default is 0.2 (20%).
8089:
8090: Returns
8091: -------
8092: Tuple[DataFrame, DataFrame]
8093: A tuple of the train set and test set DataFrames.
8094:
8095: Examples
8096: --------
8097: >>> import pandas as pd
8098: >>> from sklearn.datasets import load_iris
8099: >>> from gofast.tools.coreutils import split_train_test
8100: >>> data = load_iris(as_frame=True)['data']
8101: >>> train_set, test_set = split_train_test(data, test_ratio=0.2)
8102: >>> len(train_set), len(test_set)
8103: ... (120, 30)
8104: """
8105:
+8106: test_ratio = assert_ratio(test_ratio)
__Pyx_TraceLine(8106,0,__PYX_ERR(0, 8106, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_assert_ratio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyFloat_FromDouble(__pyx_v_test_ratio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 8106, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_test_ratio = __pyx_t_6;
8107:
+8108: shuffled_indices = np.random.permutation(len(data))
__Pyx_TraceLine(8108,0,__PYX_ERR(0, 8108, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_permutation); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8108, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_shuffled_indices = __pyx_t_1; __pyx_t_1 = 0;
+8109: test_set_size = int(len(data) * test_ratio)
__Pyx_TraceLine(8109,0,__PYX_ERR(0, 8109, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8109, __pyx_L1_error) __pyx_t_1 = __Pyx_PyInt_FromDouble((__pyx_t_7 * __pyx_v_test_ratio)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_test_set_size = __pyx_t_1; __pyx_t_1 = 0;
+8110: test_indices = shuffled_indices[:test_set_size]
__Pyx_TraceLine(8110,0,__PYX_ERR(0, 8110, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_shuffled_indices, 0, 0, NULL, &__pyx_v_test_set_size, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_test_indices = __pyx_t_1; __pyx_t_1 = 0;
+8111: train_indices = shuffled_indices[test_set_size:]
__Pyx_TraceLine(8111,0,__PYX_ERR(0, 8111, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_shuffled_indices, 0, 0, &__pyx_v_test_set_size, NULL, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_train_indices = __pyx_t_1; __pyx_t_1 = 0;
8112:
+8113: return data.iloc[train_indices], data.iloc[test_indices]
__Pyx_TraceLine(8113,0,__PYX_ERR(0, 8113, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_iloc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_train_indices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_iloc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_1, __pyx_v_test_indices); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2)) __PYX_ERR(0, 8113, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3)) __PYX_ERR(0, 8113, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
8114:
+8115: def test_set_check_id(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_262test_set_check_id(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_261test_set_check_id, "\n Check if an instance should be in the test set based on its unique identifier.\n\n Parameters\n ----------\n identifier : int\n A unique identifier for the instance.\n test_ratio : float, optional\n The ratio of instances to put in the test set. Default is 0.2 (20%).\n hash : callable\n A hash function to generate a hash from the identifier.\n Secure hashes and message digests algorithm. Can be \n SHA1, SHA224, SHA256, SHA384, and SHA512 (defined in FIPS 180-2) \n as well as RSA\342\200\231s MD5 algorithm (defined in Internet RFC 1321). \n \n Please refer to :ref:`<https://docs.python.org/3/library/hashlib.html>` \n for futher details.\n\n Returns\n -------\n bool\n True if the instance should be in the test set, False otherwise.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import test_set_check_id\n >>> test_set_check_id(42, test_ratio=0.2, hash=hashlib.md5)\n ... False\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_262test_set_check_id = {"test_set_check_id", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_262test_set_check_id, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_261test_set_check_id}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_262test_set_check_id(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_identifier = 0; double __pyx_v_test_ratio; PyObject *__pyx_v_hash = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("test_set_check_id (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_identifier,&__pyx_n_s_test_ratio,&__pyx_n_s_hash,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_identifier)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8115, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_test_ratio)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8115, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("test_set_check_id", 1, 3, 3, 1); __PYX_ERR(0, 8115, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hash)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8115, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("test_set_check_id", 1, 3, 3, 2); __PYX_ERR(0, 8115, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "test_set_check_id") < 0)) __PYX_ERR(0, 8115, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_identifier = ((PyObject*)values[0]); __pyx_v_test_ratio = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_test_ratio == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 8116, __pyx_L3_error) __pyx_v_hash = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("test_set_check_id", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 8115, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.test_set_check_id", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_identifier), (&PyInt_Type), 0, "identifier", 1))) __PYX_ERR(0, 8116, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_261test_set_check_id(__pyx_self, __pyx_v_identifier, __pyx_v_test_ratio, __pyx_v_hash); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_261test_set_check_id(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_identifier, double __pyx_v_test_ratio, PyObject *__pyx_v_hash) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__305) __Pyx_TraceCall("test_set_check_id", __pyx_f[0], 8115, 0, __PYX_ERR(0, 8115, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.test_set_check_id", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__536 = PyTuple_Pack(3, __pyx_n_s_identifier, __pyx_n_s_test_ratio, __pyx_n_s_hash); if (unlikely(!__pyx_tuple__536)) __PYX_ERR(0, 8115, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__536); __Pyx_GIVEREF(__pyx_tuple__536); /* … */ __Pyx_TraceLine(8115,0,__PYX_ERR(0, 8115, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_identifier, __pyx_n_s_int) < 0) __PYX_ERR(0, 8115, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_test_ratio, __pyx_n_s_float) < 0) __PYX_ERR(0, 8115, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_hash, __pyx_kp_s_F__T) < 0) __PYX_ERR(0, 8115, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8115, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_262test_set_check_id, 0, __pyx_n_s_test_set_check_id, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__305)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8115, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_set_check_id, __pyx_t_5) < 0) __PYX_ERR(0, 8115, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__305 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__536, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_test_set_check_id, 8115, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__305)) __PYX_ERR(0, 8115, __pyx_L1_error)
8116: identifier: int, test_ratio: float, hash: _F[_T]) -> bool:
8117: """
8118: Check if an instance should be in the test set based on its unique identifier.
8119:
8120: Parameters
8121: ----------
8122: identifier : int
8123: A unique identifier for the instance.
8124: test_ratio : float, optional
8125: The ratio of instances to put in the test set. Default is 0.2 (20%).
8126: hash : callable
8127: A hash function to generate a hash from the identifier.
8128: Secure hashes and message digests algorithm. Can be
8129: SHA1, SHA224, SHA256, SHA384, and SHA512 (defined in FIPS 180-2)
8130: as well as RSA’s MD5 algorithm (defined in Internet RFC 1321).
8131:
8132: Please refer to :ref:`<https://docs.python.org/3/library/hashlib.html>`
8133: for futher details.
8134:
8135: Returns
8136: -------
8137: bool
8138: True if the instance should be in the test set, False otherwise.
8139:
8140: Examples
8141: --------
8142: >>> from gofast.tools.coreutils import test_set_check_id
8143: >>> test_set_check_id(42, test_ratio=0.2, hash=hashlib.md5)
8144: ... False
8145: """
8146: # def test_set_check_id(identifier: str, ratio: float, hash_function: _F) -> bool:
8147: # """Determines if an identifier belongs to the test set using the hash value."""
8148: # # Convert identifier to string and hash
8149: # hash_val = int(hash_function(str(identifier).encode()).hexdigest(), 16)
8150: # # Use the hash value to decide test set membership
8151: # return hash_val % 10000 / 10000.0 < ratio
8152:
8153: # hashed_id = hash_function(identifier.encode('utf-8')).digest()
8154: # return np.frombuffer(hashed_id, dtype=np.uint8).sum() < 256 * test_ratio
+8155: return hash(np.int64(identifier)).digest()[-1] < 256 * test_ratio
__Pyx_TraceLine(8155,0,__PYX_ERR(0, 8155, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_identifier}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_INCREF(__pyx_v_hash); __pyx_t_5 = __pyx_v_hash; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_digest); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_1, -1L, long, 1, __Pyx_PyInt_From_long, 0, 1, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = PyFloat_FromDouble((256.0 * __pyx_v_test_ratio)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_RichCompare(__pyx_t_5, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8155, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
8156:
+8157: def split_train_test_by_id(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_338__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("__defaults__", __pyx_f[0], 8157, 0, __PYX_ERR(0, 8157, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
/* … */
__Pyx_TraceLine(8159,0,__PYX_ERR(0, 8159, __pyx_L1_error))
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8157, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, Py_None)) __PYX_ERR(0, 8157, __pyx_L1_error);
__Pyx_INCREF(((PyObject *)Py_True));
__Pyx_GIVEREF(((PyObject *)Py_True));
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)Py_True))) __PYX_ERR(0, 8157, __pyx_L1_error);
__Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults16, __pyx_self)->__pyx_arg_hash);
__Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults16, __pyx_self)->__pyx_arg_hash);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 2, __Pyx_CyFunction_Defaults(__pyx_defaults16, __pyx_self)->__pyx_arg_hash)) __PYX_ERR(0, 8157, __pyx_L1_error);
/* … */
__Pyx_TraceLine(8157,0,__PYX_ERR(0, 8157, __pyx_L1_error))
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8157, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GIVEREF(__pyx_t_1);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1)) __PYX_ERR(0, 8157, __pyx_L1_error);
__Pyx_INCREF(Py_None);
__Pyx_GIVEREF(Py_None);
if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None)) __PYX_ERR(0, 8157, __pyx_L1_error);
__pyx_t_1 = 0;
__pyx_r = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_AddTraceback("gofast.tools.coreutils.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_264split_train_test_by_id(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_263split_train_test_by_id, "\n Split a DataFrame into train and test sets while ensuring data consistency\n by using specified id columns or the DataFrame's index as unique identifiers.\n\n Parameters\n ----------\n data : DataFrame\n The DataFrame containing the features.\n test_ratio : float\n The ratio of instances to include in the test set.\n id_column : list of str, optional\n Column names to use as unique identifiers. If None, the DataFrame's index\n is used as the identifier.\n keep_colindex : bool, optional\n Determines whether to keep or drop the index column after resetting.\n This parameter is only applicable if id_column is None and the DataFrame's\n index is reset. Default is True.\n hash : callable\n A hash function to generate a hash from the identifier.\n\n Returns\n -------\n Tuple[DataFrame, DataFrame]\n A tuple containing the train and test set DataFrames.\n\n Examples\n --------\n >>> import pandas as pd\n >>> from gofast.tools.coreutils import split_train_test_by_id\n >>> data = pd.DataFrame({'ID': [1, 2, 3, 4, 5], 'Value': [10, 20, 30, 40, 50]})\n >>> train_set, test_set = split_train_test_by_id(data, test_ratio=0.2, id_column=['ID'])\n >>> len(train_set), len(test_set)\n (4, 1)\n ");
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_264split_train_test_by_id = {"split_train_test_by_id", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_264split_train_test_by_id, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_263split_train_test_by_id};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_264split_train_test_by_id(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_data = 0;
double __pyx_v_test_ratio;
PyObject *__pyx_v_id_column = 0;
PyObject *__pyx_v_keep_colindex = 0;
PyObject *__pyx_v_hash = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("split_train_test_by_id (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_test_ratio,&__pyx_n_s_id_column,&__pyx_n_s_keep_colindex,&__pyx_n_s_hash,0};
PyObject* values[5] = {0,0,0,0,0};
__pyx_defaults16 *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults16, __pyx_self);
/* … */
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_263split_train_test_by_id(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, double __pyx_v_test_ratio, PyObject *__pyx_v_id_column, PyObject *__pyx_v_keep_colindex, PyObject *__pyx_v_hash) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id *__pyx_cur_scope;
int __pyx_v_drop_tmp_index;
PyObject *__pyx_v_ids = NULL;
PyObject *__pyx_v_in_test_set = NULL;
PyObject *__pyx_v_train_set = NULL;
PyObject *__pyx_v_test_set = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceFrameInit(__pyx_codeobj__306)
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 8157, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__Pyx_TraceCall("split_train_test_by_id", __pyx_f[0], 8157, 0, __PYX_ERR(0, 8157, __pyx_L1_error));
__pyx_cur_scope->__pyx_v_test_ratio = __pyx_v_test_ratio;
__pyx_cur_scope->__pyx_v_hash = __pyx_v_hash;
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_hash);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_hash);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
__Pyx_AddTraceback("gofast.tools.coreutils.split_train_test_by_id", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_ids);
__Pyx_XDECREF(__pyx_v_in_test_set);
__Pyx_XDECREF(__pyx_v_train_set);
__Pyx_XDECREF(__pyx_v_test_set);
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__537 = PyTuple_Pack(10, __pyx_n_s_data, __pyx_n_s_test_ratio, __pyx_n_s_id_column, __pyx_n_s_keep_colindex, __pyx_n_s_hash, __pyx_n_s_drop_tmp_index, __pyx_n_s_ids, __pyx_n_s_in_test_set, __pyx_n_s_train_set, __pyx_n_s_test_set); if (unlikely(!__pyx_tuple__537)) __PYX_ERR(0, 8157, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__537);
__Pyx_GIVEREF(__pyx_tuple__537);
/* … */
__Pyx_TraceLine(8157,0,__PYX_ERR(0, 8157, __pyx_L1_error))
__pyx_t_5 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8157, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_n_s_DataFrame) < 0) __PYX_ERR(0, 8157, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_test_ratio, __pyx_n_s_float) < 0) __PYX_ERR(0, 8157, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_id_column, __pyx_kp_s_Optional_List_str) < 0) __PYX_ERR(0, 8157, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_keep_colindex, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8157, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_hash, __pyx_n_s_F) < 0) __PYX_ERR(0, 8157, __pyx_L1_error)
if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_Tuple_DataFrame_DataFrame) < 0) __PYX_ERR(0, 8157, __pyx_L1_error)
__pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_264split_train_test_by_id, 0, __pyx_n_s_split_train_test_by_id, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__306)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8157, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
if (!__Pyx_CyFunction_InitDefaults(__pyx_t_8, sizeof(__pyx_defaults16), 1)) __PYX_ERR(0, 8157, __pyx_L1_error)
__pyx_codeobj__306 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__537, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_split_train_test_by_id, 8157, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__306)) __PYX_ERR(0, 8157, __pyx_L1_error)
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id {
PyObject_HEAD
PyObject *__pyx_v_hash;
double __pyx_v_test_ratio;
};
+8158: data: DataFrame, test_ratio: float, id_column: Optional[List[str]] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[4] = __Pyx_Arg_NewRef_FASTCALL(__pyx_dynamic_args->__pyx_arg_hash); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8157, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_test_ratio)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8157, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("split_train_test_by_id", 0, 2, 5, 1); __PYX_ERR(0, 8157, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_id_column); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8157, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_keep_colindex); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8157, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_hash); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8157, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "split_train_test_by_id") < 0)) __PYX_ERR(0, 8157, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_data = values[0]; __pyx_v_test_ratio = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_test_ratio == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 8158, __pyx_L3_error) __pyx_v_id_column = values[2]; __pyx_v_keep_colindex = values[3]; __pyx_v_hash = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("split_train_test_by_id", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 8157, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.split_train_test_by_id", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_263split_train_test_by_id(__pyx_self, __pyx_v_data, __pyx_v_test_ratio, __pyx_v_id_column, __pyx_v_keep_colindex, __pyx_v_hash);
+8159: keep_colindex: bool = True, hash: _F = hashlib.md5
__Pyx_TraceLine(8159,0,__PYX_ERR(0, 8159, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_hashlib); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_md5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_CyFunction_Defaults(__pyx_defaults16, __pyx_t_8)->__pyx_arg_hash = __pyx_t_4; __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_8, __pyx_pf_6gofast_5tools_9coreutils_338__defaults__); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_split_train_test_by_id, __pyx_t_8) < 0) __PYX_ERR(0, 8157, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
8160: ) -> Tuple[DataFrame, DataFrame]:
8161: """
8162: Split a DataFrame into train and test sets while ensuring data consistency
8163: by using specified id columns or the DataFrame's index as unique identifiers.
8164:
8165: Parameters
8166: ----------
8167: data : DataFrame
8168: The DataFrame containing the features.
8169: test_ratio : float
8170: The ratio of instances to include in the test set.
8171: id_column : list of str, optional
8172: Column names to use as unique identifiers. If None, the DataFrame's index
8173: is used as the identifier.
8174: keep_colindex : bool, optional
8175: Determines whether to keep or drop the index column after resetting.
8176: This parameter is only applicable if id_column is None and the DataFrame's
8177: index is reset. Default is True.
8178: hash : callable
8179: A hash function to generate a hash from the identifier.
8180:
8181: Returns
8182: -------
8183: Tuple[DataFrame, DataFrame]
8184: A tuple containing the train and test set DataFrames.
8185:
8186: Examples
8187: --------
8188: >>> import pandas as pd
8189: >>> from gofast.tools.coreutils import split_train_test_by_id
8190: >>> data = pd.DataFrame({'ID': [1, 2, 3, 4, 5], 'Value': [10, 20, 30, 40, 50]})
8191: >>> train_set, test_set = split_train_test_by_id(data, test_ratio=0.2, id_column=['ID'])
8192: >>> len(train_set), len(test_set)
8193: (4, 1)
8194: """
+8195: drop_tmp_index=False
__Pyx_TraceLine(8195,0,__PYX_ERR(0, 8195, __pyx_L1_error)) __pyx_v_drop_tmp_index = 0;
+8196: if id_column is None:
__Pyx_TraceLine(8196,0,__PYX_ERR(0, 8196, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_id_column == Py_None); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
8197: # Check if the index is integer-based; if not, create a temporary integer index.
+8198: if not data.index.is_integer():
__Pyx_TraceLine(8198,0,__PYX_ERR(0, 8198, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_is_integer); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (!__pyx_t_1); if (__pyx_t_6) { /* … */ goto __pyx_L4; }
+8199: data['_tmp_hash_index'] = np.arange(len(data))
__Pyx_TraceLine(8199,0,__PYX_ERR(0, 8199, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_arange); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_7 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8199, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8199, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (unlikely((PyObject_SetItem(__pyx_v_data, __pyx_n_u_tmp_hash_index, __pyx_t_2) < 0))) __PYX_ERR(0, 8199, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+8200: ids = data['_tmp_hash_index']
__Pyx_TraceLine(8200,0,__PYX_ERR(0, 8200, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_data, __pyx_n_u_tmp_hash_index); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8200, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_ids = __pyx_t_2; __pyx_t_2 = 0;
+8201: drop_tmp_index = True
__Pyx_TraceLine(8201,0,__PYX_ERR(0, 8201, __pyx_L1_error)) __pyx_v_drop_tmp_index = 1;
8202: else:
+8203: ids = data.index.to_series()
__Pyx_TraceLine(8203,0,__PYX_ERR(0, 8203, __pyx_L1_error)) /*else*/ { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_index); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_to_series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8203, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_ids = __pyx_t_2; __pyx_t_2 = 0;
+8204: drop_tmp_index = False
__Pyx_TraceLine(8204,0,__PYX_ERR(0, 8204, __pyx_L1_error)) __pyx_v_drop_tmp_index = 0; } __pyx_L4:;
8205: else:
8206: # Use specified id columns as unique identifiers, combining them if necessary.
+8207: ids = data[id_column].astype(str).apply(
__Pyx_TraceLine(8207,0,__PYX_ERR(0, 8207, __pyx_L1_error)) /*else*/ { /* … */ __Pyx_TraceLine(8207,0,__PYX_ERR(0, 8207, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_v_id_column); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_astype); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_8))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_8, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, ((PyObject *)(&PyUnicode_Type))}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_8, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_apply); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(8207,0,__PYX_ERR(0, 8207, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_4); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4)) __PYX_ERR(0, 8207, __pyx_L1_error); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(8207,0,__PYX_ERR(0, 8207, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __pyx_t_9; __pyx_t_9 = 0; } else {
+8208: lambda row: '_'.join(row), axis=1) if isinstance(
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22split_train_test_by_id_lambda33(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22split_train_test_by_id_lambda33 = {"lambda33", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22split_train_test_by_id_lambda33, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22split_train_test_by_id_lambda33(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_row = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda33 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_row,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_row)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8208, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda33") < 0)) __PYX_ERR(0, 8208, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_row = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda33", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 8208, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.split_train_test_by_id.lambda33", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda33(__pyx_self, __pyx_v_row);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda33(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_row) {
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__Pyx_TraceCall("lambda33", __pyx_f[0], 8208, 0, __PYX_ERR(0, 8208, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = PyUnicode_Join(__pyx_n_u__8, __pyx_v_row); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8208, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_AddTraceback("gofast.tools.coreutils.split_train_test_by_id.lambda33", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(8208,0,__PYX_ERR(0, 8208, __pyx_L1_error))
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22split_train_test_by_id_lambda33, 0, __pyx_n_s_split_train_test_by_id_locals_la, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8208, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
/* … */
__Pyx_TraceLine(8208,0,__PYX_ERR(0, 8208, __pyx_L1_error))
__pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8208, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 8208, __pyx_L1_error)
+8209: id_column, list) else data[id_column]
__Pyx_TraceLine(8209,0,__PYX_ERR(0, 8209, __pyx_L1_error)) __pyx_t_6 = PyList_Check(__pyx_v_id_column); if (__pyx_t_6) { /* … */ __Pyx_TraceLine(8209,0,__PYX_ERR(0, 8209, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_data, __pyx_v_id_column); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8209, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_2 = __pyx_t_9; __pyx_t_9 = 0; } __pyx_v_ids = __pyx_t_2; __pyx_t_2 = 0; } __pyx_L3:;
8210:
+8211: in_test_set = ids.apply(lambda id_: test_set_check_id(id_, test_ratio, hash))
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22split_train_test_by_id_1lambda34(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22split_train_test_by_id_1lambda34 = {"lambda34", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22split_train_test_by_id_1lambda34, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22split_train_test_by_id_1lambda34(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_id_ = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda34 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_id,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_id)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8211, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda34") < 0)) __PYX_ERR(0, 8211, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_id_ = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda34", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 8211, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.split_train_test_by_id.lambda34", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda34(__pyx_self, __pyx_v_id_);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda34(PyObject *__pyx_self, PyObject *__pyx_v_id_) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_32_split_train_test_by_id *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda34", __pyx_f[0], 8211, 0, __PYX_ERR(0, 8211, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_test_set_check_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_test_ratio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (unlikely(!__pyx_cur_scope->__pyx_v_hash)) { __Pyx_RaiseClosureNameError("hash"); __PYX_ERR(0, 8211, __pyx_L1_error) }
__pyx_t_4 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (unlikely(PyMethod_Check(__pyx_t_2))) {
__pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
if (likely(__pyx_t_4)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
__Pyx_INCREF(__pyx_t_4);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_2, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_v_id_, __pyx_t_3, __pyx_cur_scope->__pyx_v_hash};
__pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 3+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("gofast.tools.coreutils.split_train_test_by_id.lambda34", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(8211,0,__PYX_ERR(0, 8211, __pyx_L1_error))
__pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_ids, __pyx_n_s_apply); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22split_train_test_by_id_1lambda34, 0, __pyx_n_s_split_train_test_by_id_locals_la, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = NULL;
__pyx_t_5 = 0;
#if CYTHON_UNPACK_METHODS
if (likely(PyMethod_Check(__pyx_t_9))) {
__pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
if (likely(__pyx_t_3)) {
PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(function);
__Pyx_DECREF_SET(__pyx_t_9, function);
__pyx_t_5 = 1;
}
}
#endif
{
PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
__pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8211, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
}
__pyx_v_in_test_set = __pyx_t_2;
__pyx_t_2 = 0;
8212:
+8213: train_set = data.loc[~in_test_set].copy()
__Pyx_TraceLine(8213,0,__PYX_ERR(0, 8213, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_loc); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = PyNumber_Invert(__pyx_v_in_test_set); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8213, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_train_set = __pyx_t_2; __pyx_t_2 = 0;
+8214: test_set = data.loc[in_test_set].copy()
__Pyx_TraceLine(8214,0,__PYX_ERR(0, 8214, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_loc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_v_in_test_set); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8214, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_v_test_set = __pyx_t_2; __pyx_t_2 = 0;
8215:
+8216: if drop_tmp_index or (id_column is None and not keep_colindex):
__Pyx_TraceLine(8216,0,__PYX_ERR(0, 8216, __pyx_L1_error)) if (!__pyx_v_drop_tmp_index) { } else { __pyx_t_6 = __pyx_v_drop_tmp_index; goto __pyx_L6_bool_binop_done; } __pyx_t_1 = (__pyx_v_id_column == Py_None); if (__pyx_t_1) { } else { __pyx_t_6 = __pyx_t_1; goto __pyx_L6_bool_binop_done; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_keep_colindex); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8216, __pyx_L1_error) __pyx_t_10 = (!__pyx_t_1); __pyx_t_6 = __pyx_t_10; __pyx_L6_bool_binop_done:; if (__pyx_t_6) { /* … */ goto __pyx_L5; }
8217: # Remove the temporary index or reset the index as needed
+8218: train_set.drop(columns=['_tmp_hash_index'], errors='ignore', inplace=True)
__Pyx_TraceLine(8218,0,__PYX_ERR(0, 8218, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_train_set, __pyx_n_s_drop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_n_u_tmp_hash_index); __Pyx_GIVEREF(__pyx_n_u_tmp_hash_index); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_u_tmp_hash_index)) __PYX_ERR(0, 8218, __pyx_L1_error); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_columns, __pyx_t_3) < 0) __PYX_ERR(0, 8218, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_errors, __pyx_n_u_ignore) < 0) __PYX_ERR(0, 8218, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 8218, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8218, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+8219: test_set.drop(columns=['_tmp_hash_index'], errors='ignore', inplace=True)
__Pyx_TraceLine(8219,0,__PYX_ERR(0, 8219, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_test_set, __pyx_n_s_drop); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_u_tmp_hash_index); __Pyx_GIVEREF(__pyx_n_u_tmp_hash_index); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_u_tmp_hash_index)) __PYX_ERR(0, 8219, __pyx_L1_error); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_columns, __pyx_t_2) < 0) __PYX_ERR(0, 8219, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_errors, __pyx_n_u_ignore) < 0) __PYX_ERR(0, 8219, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 8219, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8219, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8220: # for consistency if '_tmp_has_index'
+8221: if '_tmp_hash_index' in data.columns:
__Pyx_TraceLine(8221,0,__PYX_ERR(0, 8221, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_columns); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_tmp_hash_index, __pyx_t_2, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 8221, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ }
+8222: data.drop (columns='_tmp_hash_index', inplace =True)
__Pyx_TraceLine(8222,0,__PYX_ERR(0, 8222, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_data, __pyx_n_s_drop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_columns, __pyx_n_u_tmp_hash_index) < 0) __PYX_ERR(0, 8222, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_inplace, Py_True) < 0) __PYX_ERR(0, 8222, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8222, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+8223: elif id_column is None and keep_colindex:
__Pyx_TraceLine(8223,0,__PYX_ERR(0, 8223, __pyx_L1_error)) __pyx_t_10 = (__pyx_v_id_column == Py_None); if (__pyx_t_10) { } else { __pyx_t_6 = __pyx_t_10; goto __pyx_L10_bool_binop_done; } __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_keep_colindex); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 8223, __pyx_L1_error) __pyx_t_6 = __pyx_t_10; __pyx_L10_bool_binop_done:; if (__pyx_t_6) { } __pyx_L5:;
8224: # If keeping the original index and it was integer-based, no action needed
8225: pass
8226:
+8227: return train_set, test_set
__Pyx_TraceLine(8227,0,__PYX_ERR(0, 8227, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8227, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_train_set); __Pyx_GIVEREF(__pyx_v_train_set); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_train_set)) __PYX_ERR(0, 8227, __pyx_L1_error); __Pyx_INCREF(__pyx_v_test_set); __Pyx_GIVEREF(__pyx_v_test_set); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_test_set)) __PYX_ERR(0, 8227, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
8228:
+8229: def parallelize_jobs(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_266parallelize_jobs(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_265parallelize_jobs, "\n Parallelize the execution of a callable across multiple processors, \n supporting both positional and keyword arguments.\n\n Parameters\n ----------\n function : Callable[..., Any]\n The function to execute in parallel. This function must be picklable \n if using `executor_type='process'`.\n tasks : Sequence[Dict[str, Any]], optional\n A sequence of dictionaries, where each dictionary contains \n two keys: 'args' (a tuple) for positional arguments,\n and 'kwargs' (a dict) for keyword arguments, for one execution of\n `function`. Defaults to an empty sequence.\n n_jobs : Optional[int], optional\n The number of jobs to run in parallel. `None` or `1` uses a single \n processor, any positive integer specifies the\n exact number of processors to use, `-1` uses all available processors. \n Default is None (1 processor).\n executor_type : str, optional\n The type of executor to use. Can be 'process' for CPU-bound tasks or\n 'thread' for I/O-bound tasks. Default is 'process'.\n\n Returns\n -------\n list\n A list of results from the function executions.\n\n Raises\n ------\n ValueError\n If `function` is not picklable when using 'process' as `executor_type`.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import parallelize_jobs\n >>> def greet(name, greeting='Hello'):\n ... return f\"{greeting}, {name}!\"\n >>> tasks = [\n ... {'args': ('John',), 'kwargs': {'greeting': 'Hi'}},\n ... {'args': ('Jane',), 'kwargs': {}}\n ... ]\n >>> results = parallelize_jobs(greet, tasks, n_jobs=2)\n >>> print(results)\n ['Hi, John!', 'Hello, Jane!']\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_266parallelize_jobs = {"parallelize_jobs", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_266parallelize_jobs, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_265parallelize_jobs}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_266parallelize_jobs(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_function = 0; PyObject *__pyx_v_tasks = 0; PyObject *__pyx_v_n_jobs = 0; PyObject *__pyx_v_executor_type = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("parallelize_jobs (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_function,&__pyx_n_s_tasks,&__pyx_n_s_n_jobs,&__pyx_n_s_executor_type,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_265parallelize_jobs(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_function, PyObject *__pyx_v_tasks, PyObject *__pyx_v_n_jobs, PyObject *__pyx_v_executor_type) { PyObject *__pyx_v_cloudpickle = NULL; PyObject *__pyx_v_num_workers = NULL; PyObject *__pyx_v_ExecutorClass = NULL; PyObject *__pyx_v_results = NULL; PyObject *__pyx_v_executor = NULL; PyObject *__pyx_v_futures = NULL; PyObject *__pyx_v_future = NULL; PyObject *__pyx_9genexpr75__pyx_v_task = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__307) __Pyx_TraceCall("parallelize_jobs", __pyx_f[0], 8229, 0, __PYX_ERR(0, 8229, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_14); __Pyx_XDECREF(__pyx_t_15); __Pyx_XDECREF(__pyx_t_16); __Pyx_XDECREF(__pyx_t_17); __Pyx_XDECREF(__pyx_t_18); __Pyx_AddTraceback("gofast.tools.coreutils.parallelize_jobs", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cloudpickle); __Pyx_XDECREF(__pyx_v_num_workers); __Pyx_XDECREF(__pyx_v_ExecutorClass); __Pyx_XDECREF(__pyx_v_results); __Pyx_XDECREF(__pyx_v_executor); __Pyx_XDECREF(__pyx_v_futures); __Pyx_XDECREF(__pyx_v_future); __Pyx_XDECREF(__pyx_9genexpr75__pyx_v_task); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__538 = PyTuple_Pack(12, __pyx_n_s_function, __pyx_n_s_tasks, __pyx_n_s_n_jobs, __pyx_n_s_executor_type, __pyx_n_s_cloudpickle, __pyx_n_s_num_workers, __pyx_n_s_ExecutorClass, __pyx_n_s_results, __pyx_n_s_executor, __pyx_n_s_futures, __pyx_n_s_future, __pyx_n_s_task); if (unlikely(!__pyx_tuple__538)) __PYX_ERR(0, 8229, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__538); __Pyx_GIVEREF(__pyx_tuple__538); __pyx_codeobj__307 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__538, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_parallelize_jobs, 8229, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__307)) __PYX_ERR(0, 8229, __pyx_L1_error) /* … */ __Pyx_TraceLine(8229,0,__PYX_ERR(0, 8229, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_function, __pyx_n_s_F) < 0) __PYX_ERR(0, 8229, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_tasks, __pyx_kp_s_Sequence_Dict_str_Any) < 0) __PYX_ERR(0, 8229, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_n_jobs, __pyx_kp_s_Optional_int) < 0) __PYX_ERR(0, 8229, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_executor_type, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 8229, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_list) < 0) __PYX_ERR(0, 8229, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_266parallelize_jobs, 0, __pyx_n_s_parallelize_jobs, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__307)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8229, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__539); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_parallelize_jobs, __pyx_t_5) < 0) __PYX_ERR(0, 8229, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__539 = PyTuple_Pack(3, ((PyObject*)__pyx_empty_tuple), Py_None, ((PyObject*)__pyx_n_u_process)); if (unlikely(!__pyx_tuple__539)) __PYX_ERR(0, 8229, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__539); __Pyx_GIVEREF(__pyx_tuple__539);
8230: function: _F,
+8231: tasks: Sequence[Dict[str, Any]] = (),
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_empty_tuple)));
+8232: n_jobs: Optional[int] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_process))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_function)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8229, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_tasks); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8229, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n_jobs); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8229, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_executor_type); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8229, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "parallelize_jobs") < 0)) __PYX_ERR(0, 8229, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_function = values[0]; __pyx_v_tasks = values[1]; __pyx_v_n_jobs = values[2]; __pyx_v_executor_type = ((PyObject*)values[3]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("parallelize_jobs", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 8229, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.parallelize_jobs", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_executor_type), (&PyUnicode_Type), 0, "executor_type", 1))) __PYX_ERR(0, 8233, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_265parallelize_jobs(__pyx_self, __pyx_v_function, __pyx_v_tasks, __pyx_v_n_jobs, __pyx_v_executor_type);
8233: executor_type: str = 'process') -> list:
8234: """
8235: Parallelize the execution of a callable across multiple processors,
8236: supporting both positional and keyword arguments.
8237:
8238: Parameters
8239: ----------
8240: function : Callable[..., Any]
8241: The function to execute in parallel. This function must be picklable
8242: if using `executor_type='process'`.
8243: tasks : Sequence[Dict[str, Any]], optional
8244: A sequence of dictionaries, where each dictionary contains
8245: two keys: 'args' (a tuple) for positional arguments,
8246: and 'kwargs' (a dict) for keyword arguments, for one execution of
8247: `function`. Defaults to an empty sequence.
8248: n_jobs : Optional[int], optional
8249: The number of jobs to run in parallel. `None` or `1` uses a single
8250: processor, any positive integer specifies the
8251: exact number of processors to use, `-1` uses all available processors.
8252: Default is None (1 processor).
8253: executor_type : str, optional
8254: The type of executor to use. Can be 'process' for CPU-bound tasks or
8255: 'thread' for I/O-bound tasks. Default is 'process'.
8256:
8257: Returns
8258: -------
8259: list
8260: A list of results from the function executions.
8261:
8262: Raises
8263: ------
8264: ValueError
8265: If `function` is not picklable when using 'process' as `executor_type`.
8266:
8267: Examples
8268: --------
8269: >>> from gofast.tools.coreutils import parallelize_jobs
8270: >>> def greet(name, greeting='Hello'):
8271: ... return f"{greeting}, {name}!"
8272: >>> tasks = [
8273: ... {'args': ('John',), 'kwargs': {'greeting': 'Hi'}},
8274: ... {'args': ('Jane',), 'kwargs': {}}
8275: ... ]
8276: >>> results = parallelize_jobs(greet, tasks, n_jobs=2)
8277: >>> print(results)
8278: ['Hi, John!', 'Hello, Jane!']
8279: """
+8280: if executor_type == 'process':
__Pyx_TraceLine(8280,0,__PYX_ERR(0, 8280, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_executor_type, __pyx_n_u_process, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8280, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+8281: import_optional_dependency("cloudpickle")
__Pyx_TraceLine(8281,0,__PYX_ERR(0, 8281, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_import_optional_dependency); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_n_u_cloudpickle}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8281, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+8282: import cloudpickle
__Pyx_TraceLine(8282,0,__PYX_ERR(0, 8282, __pyx_L1_error)) __pyx_t_2 = __Pyx_ImportDottedModule(__pyx_n_s_cloudpickle, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_cloudpickle = __pyx_t_2; __pyx_t_2 = 0;
+8283: try:
__Pyx_TraceLine(8283,0,__PYX_ERR(0, 8283, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L9_try_end; __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L9_try_end:; }
+8284: cloudpickle.dumps(function)
__Pyx_TraceLine(8284,0,__PYX_ERR(0, 8284, __pyx_L4_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_cloudpickle, __pyx_n_s_dumps); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8284, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_function}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8284, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+8285: except cloudpickle.PicklingError:
__Pyx_TraceLine(8285,0,__PYX_ERR(0, 8285, __pyx_L6_except_error)) __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_cloudpickle, __pyx_n_s_PicklingError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8285, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_5 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_ErrRestore(__pyx_t_2, __pyx_t_3, __pyx_t_4); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_4 = 0; if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils.parallelize_jobs", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 8285, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2);
+8286: raise ValueError("The function to be parallelized must be "
__Pyx_TraceLine(8286,0,__PYX_ERR(0, 8286, __pyx_L6_except_error)) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__308, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8286, __pyx_L6_except_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 8286, __pyx_L6_except_error) } goto __pyx_L6_except_error; /* … */ __pyx_tuple__308 = PyTuple_Pack(1, __pyx_kp_u_The_function_to_be_parallelized); if (unlikely(!__pyx_tuple__308)) __PYX_ERR(0, 8286, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__308); __Pyx_GIVEREF(__pyx_tuple__308);
8287: "picklable when using 'process' executor.")
8288:
+8289: num_workers = multiprocessing.cpu_count() if n_jobs == -1 else (
__Pyx_TraceLine(8289,0,__PYX_ERR(0, 8289, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyInt_BoolEqObjC(__pyx_v_n_jobs, __pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8289, __pyx_L1_error) if (__pyx_t_1) { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_multiprocessing); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_cpu_count); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else {
+8290: 1 if n_jobs is None else n_jobs)
__Pyx_TraceLine(8290,0,__PYX_ERR(0, 8290, __pyx_L1_error)) __pyx_t_10 = (__pyx_v_n_jobs == Py_None); if (__pyx_t_10) { __Pyx_INCREF(__pyx_int_1); __pyx_t_3 = __pyx_int_1; } else { __Pyx_INCREF(__pyx_v_n_jobs); __pyx_t_3 = __pyx_v_n_jobs; } __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_num_workers = __pyx_t_2; __pyx_t_2 = 0;
8291:
+8292: ExecutorClass = ProcessPoolExecutor if executor_type == 'process' \
__Pyx_TraceLine(8292,0,__PYX_ERR(0, 8292, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_executor_type, __pyx_n_u_process, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8292, __pyx_L1_error) if (__pyx_t_1) { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ProcessPoolExecutor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8292, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } else {
+8293: else ThreadPoolExecutor
__Pyx_TraceLine(8293,0,__PYX_ERR(0, 8293, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_ThreadPoolExecutor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8293, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_ExecutorClass = __pyx_t_2; __pyx_t_2 = 0;
8294:
+8295: results = []
__Pyx_TraceLine(8295,0,__PYX_ERR(0, 8295, __pyx_L1_error)) __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8295, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_results = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+8296: with ExecutorClass(max_workers=num_workers) as executor:
__Pyx_TraceLine(8296,0,__PYX_ERR(0, 8296, __pyx_L1_error)) /*with:*/ { __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_max_workers, __pyx_v_num_workers) < 0) __PYX_ERR(0, 8296, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_ExecutorClass, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_exit); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_n_s_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8296, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_9))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8296, __pyx_L12_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /*try:*/ { { /*try:*/ { __pyx_v_executor = __pyx_t_9; __pyx_t_9 = 0; /* … */ } __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L21_try_end; __pyx_L16_error:; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0; __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /*except:*/ { __Pyx_AddTraceback("gofast.tools.coreutils.parallelize_jobs", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 8296, __pyx_L18_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_4); __pyx_t_14 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8296, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_14, NULL); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 8296, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_20); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; if (__pyx_t_1 < 0) __PYX_ERR(0, 8296, __pyx_L18_except_error) __pyx_t_10 = (!__pyx_t_1); if (unlikely(__pyx_t_10)) { __Pyx_GIVEREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_9, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_9 = 0; __pyx_t_4 = 0; __PYX_ERR(0, 8296, __pyx_L18_except_error) } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L17_exception_handled; } __pyx_L18_except_error:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_11); goto __pyx_L1_error; __pyx_L17_exception_handled:; __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_11); __pyx_L21_try_end:; } } /*finally:*/ { /*normal exit:*/{ if (__pyx_t_8) { __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_tuple__84, NULL); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8296, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } goto __pyx_L15; } __pyx_L15:; } goto __pyx_L35; __pyx_L12_error:; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L1_error; __pyx_L35:; }
+8297: futures = [executor.submit(function, *task.get('args', ()),
__Pyx_TraceLine(8297,0,__PYX_ERR(0, 8297, __pyx_L16_error)) { /* enter inner scope */ __pyx_t_9 = PyList_New(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_9); /* … */ __Pyx_TraceLine(8297,0,__PYX_ERR(0, 8297, __pyx_L24_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_executor, __pyx_n_s_submit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_function); __Pyx_GIVEREF(__pyx_v_function); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_function)) __PYX_ERR(0, 8297, __pyx_L24_error); __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr75__pyx_v_task, __pyx_n_s_get); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_14); __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_tuple__309, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_14 = __Pyx_PySequence_Tuple(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __pyx_t_15 = PyNumber_Add(__pyx_t_4, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; /* … */ __Pyx_TraceLine(8297,0,__PYX_ERR(0, 8297, __pyx_L24_error)) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_15, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_9, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_tuple__309 = PyTuple_Pack(2, __pyx_n_u_args, __pyx_empty_tuple); if (unlikely(!__pyx_tuple__309)) __PYX_ERR(0, 8297, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__309); __Pyx_GIVEREF(__pyx_tuple__309);
+8298: **task.get('kwargs', {})) for task in tasks]
__Pyx_TraceLine(8298,0,__PYX_ERR(0, 8298, __pyx_L24_error)) if (likely(PyList_CheckExact(__pyx_v_tasks)) || PyTuple_CheckExact(__pyx_v_tasks)) { __pyx_t_3 = __pyx_v_tasks; __Pyx_INCREF(__pyx_t_3); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_tasks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8298, __pyx_L24_error) } for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8298, __pyx_L24_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 8298, __pyx_L24_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_2); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8298, __pyx_L24_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_2); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 8298, __pyx_L24_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_2); #endif } } else { __pyx_t_2 = __pyx_t_13(__pyx_t_3); if (unlikely(!__pyx_t_2)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 8298, __pyx_L24_error) } break; } __Pyx_GOTREF(__pyx_t_2); } __Pyx_XDECREF_SET(__pyx_9genexpr75__pyx_v_task, __pyx_t_2); __pyx_t_2 = 0; /* … */ __Pyx_TraceLine(8298,0,__PYX_ERR(0, 8298, __pyx_L24_error)) __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_9genexpr75__pyx_v_task, __pyx_n_s_get); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_16); __pyx_t_17 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_16))) { __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_16); if (likely(__pyx_t_18)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16); __Pyx_INCREF(__pyx_t_18); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_16, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_n_u_kwargs, __pyx_t_17}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_16, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; } if (unlikely(__pyx_t_4 == Py_None)) { PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType"); __PYX_ERR(0, 8298, __pyx_L24_error) } if (likely(PyDict_CheckExact(__pyx_t_4))) { __pyx_t_14 = PyDict_Copy(__pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8298, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { __pyx_t_14 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8297, __pyx_L24_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } /* … */ __Pyx_TraceLine(8298,0,__PYX_ERR(0, 8298, __pyx_L24_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr75__pyx_v_task); __pyx_9genexpr75__pyx_v_task = 0; goto __pyx_L28_exit_scope; __pyx_L24_error:; __Pyx_XDECREF(__pyx_9genexpr75__pyx_v_task); __pyx_9genexpr75__pyx_v_task = 0; goto __pyx_L16_error; __pyx_L28_exit_scope:; } /* exit inner scope */ __pyx_v_futures = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0;
8299:
+8300: for future in as_completed(futures):
__Pyx_TraceLine(8300,0,__PYX_ERR(0, 8300, __pyx_L16_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_as_completed); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8300, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_futures}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8300, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } if (likely(PyList_CheckExact(__pyx_t_9)) || PyTuple_CheckExact(__pyx_t_9)) { __pyx_t_3 = __pyx_t_9; __Pyx_INCREF(__pyx_t_3); __pyx_t_12 = 0; __pyx_t_13 = NULL; } else { __pyx_t_12 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8300, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8300, __pyx_L16_error) } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; for (;;) { if (likely(!__pyx_t_13)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8300, __pyx_L16_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 8300, __pyx_L16_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8300, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8300, __pyx_L16_error) #endif if (__pyx_t_12 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_12); __Pyx_INCREF(__pyx_t_9); __pyx_t_12++; if (unlikely((0 < 0))) __PYX_ERR(0, 8300, __pyx_L16_error) #else __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8300, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); #endif } } else { __pyx_t_9 = __pyx_t_13(__pyx_t_3); if (unlikely(!__pyx_t_9)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 8300, __pyx_L16_error) } break; } __Pyx_GOTREF(__pyx_t_9); } __Pyx_XDECREF_SET(__pyx_v_future, __pyx_t_9); __pyx_t_9 = 0; /* … */ __Pyx_TraceLine(8300,0,__PYX_ERR(0, 8300, __pyx_L16_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+8301: results.append(future.result())
__Pyx_TraceLine(8301,0,__PYX_ERR(0, 8301, __pyx_L16_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_future, __pyx_n_s_result); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8301, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_14 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_14)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8301, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_19 = __Pyx_PyList_Append(__pyx_v_results, __pyx_t_9); if (unlikely(__pyx_t_19 == ((int)-1))) __PYX_ERR(0, 8301, __pyx_L16_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
8302:
+8303: return results
__Pyx_TraceLine(8303,0,__PYX_ERR(0, 8303, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_results); __pyx_r = __pyx_v_results; goto __pyx_L0;
8304:
+8305: def denormalize(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_268denormalize(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_267denormalize, "\n Denormalizes data from a normalized scale back to its original scale.\n\n This function is useful when data has been normalized to a different \n scale (e.g., [0, 1]) and needs to be converted back to its original scale \n for interpretation or further processing.\n\n Parameters\n ----------\n data : np.ndarray\n The data to be denormalized, assumed to be a NumPy array.\n min_value : float\n The minimum value of the original scale before normalization.\n max_value : float\n The maximum value of the original scale before normalization.\n\n Returns\n -------\n np.ndarray\n The denormalized data, converted back to its original scale.\n\n Examples\n --------\n >>> import numpy as np\n >>> from gofast.tools.coreutils import denormalize\n >>> normalized_data = np.array([0, 0.5, 1])\n >>> min_value = 10\n >>> max_value = 20\n >>> denormalized_data = denormalize(normalized_data, min_value, max_value)\n >>> print(denormalized_data)\n [10. 15. 20.]\n\n Note\n ----\n The denormalization process is the inverse of normalization and is applied\n to data that was previously normalized according to the formula:\n `data_norm = (data - min_value) / (max_value - min_value)`\n The denormalize function uses the inverse of this formula to restore the data.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_268denormalize = {"denormalize", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_268denormalize, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_267denormalize}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_268denormalize(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_data = 0; double __pyx_v_min_value; double __pyx_v_max_value; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("denormalize (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_min_value,&__pyx_n_s_max_value,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8305, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_min_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8305, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("denormalize", 1, 3, 3, 1); __PYX_ERR(0, 8305, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_value)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8305, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("denormalize", 1, 3, 3, 2); __PYX_ERR(0, 8305, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "denormalize") < 0)) __PYX_ERR(0, 8305, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_data = values[0]; __pyx_v_min_value = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_min_value == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 8306, __pyx_L3_error) __pyx_v_max_value = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_max_value == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 8306, __pyx_L3_error) } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("denormalize", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 8305, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.denormalize", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_267denormalize(__pyx_self, __pyx_v_data, __pyx_v_min_value, __pyx_v_max_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_267denormalize(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_data, double __pyx_v_min_value, double __pyx_v_max_value) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__310) __Pyx_TraceCall("denormalize", __pyx_f[0], 8305, 0, __PYX_ERR(0, 8305, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_data); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.denormalize", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__540 = PyTuple_Pack(3, __pyx_n_s_data, __pyx_n_s_min_value, __pyx_n_s_max_value); if (unlikely(!__pyx_tuple__540)) __PYX_ERR(0, 8305, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__540); __Pyx_GIVEREF(__pyx_tuple__540); /* … */ __Pyx_TraceLine(8305,0,__PYX_ERR(0, 8305, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_n_s_ArrayLike) < 0) __PYX_ERR(0, 8305, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_min_value, __pyx_n_s_float) < 0) __PYX_ERR(0, 8305, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_max_value, __pyx_n_s_float) < 0) __PYX_ERR(0, 8305, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_ArrayLike) < 0) __PYX_ERR(0, 8305, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_268denormalize, 0, __pyx_n_s_denormalize, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__310)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_denormalize, __pyx_t_8) < 0) __PYX_ERR(0, 8305, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__310 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__540, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_denormalize, 8305, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__310)) __PYX_ERR(0, 8305, __pyx_L1_error)
8306: data: ArrayLike, min_value: float, max_value: float
8307: ) -> ArrayLike:
8308: """
8309: Denormalizes data from a normalized scale back to its original scale.
8310:
8311: This function is useful when data has been normalized to a different
8312: scale (e.g., [0, 1]) and needs to be converted back to its original scale
8313: for interpretation or further processing.
8314:
8315: Parameters
8316: ----------
8317: data : np.ndarray
8318: The data to be denormalized, assumed to be a NumPy array.
8319: min_value : float
8320: The minimum value of the original scale before normalization.
8321: max_value : float
8322: The maximum value of the original scale before normalization.
8323:
8324: Returns
8325: -------
8326: np.ndarray
8327: The denormalized data, converted back to its original scale.
8328:
8329: Examples
8330: --------
8331: >>> import numpy as np
8332: >>> from gofast.tools.coreutils import denormalize
8333: >>> normalized_data = np.array([0, 0.5, 1])
8334: >>> min_value = 10
8335: >>> max_value = 20
8336: >>> denormalized_data = denormalize(normalized_data, min_value, max_value)
8337: >>> print(denormalized_data)
8338: [10. 15. 20.]
8339:
8340: Note
8341: ----
8342: The denormalization process is the inverse of normalization and is applied
8343: to data that was previously normalized according to the formula:
8344: `data_norm = (data - min_value) / (max_value - min_value)`
8345: The denormalize function uses the inverse of this formula to restore the data.
8346: """
+8347: if not isinstance (data, (pd.Series, pd.DataFrame)):
__Pyx_TraceLine(8347,0,__PYX_ERR(0, 8347, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8347, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_t_2); if (!__pyx_t_5) { } else { __pyx_t_4 = __pyx_t_5; goto __pyx_L4_bool_binop_done; } __pyx_t_5 = PyObject_IsInstance(__pyx_v_data, __pyx_t_3); __pyx_t_4 = __pyx_t_5; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = (!__pyx_t_4); if (__pyx_t_5) { /* … */ }
+8348: data = np.asarray( data )
__Pyx_TraceLine(8348,0,__PYX_ERR(0, 8348, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_asarray); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_data}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8348, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_2); __pyx_t_2 = 0;
8349:
+8350: return data * (max_value - min_value) + min_value
__Pyx_TraceLine(8350,0,__PYX_ERR(0, 8350, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyFloat_FromDouble((__pyx_v_max_value - __pyx_v_min_value)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = PyNumber_Multiply(__pyx_v_data, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyFloat_FromDouble(__pyx_v_min_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8350, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
8351:
+8352: def download_progress_hook(t):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_270download_progress_hook(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_269download_progress_hook, "\n Hook to update the tqdm progress bar during a download.\n\n Parameters\n ----------\n t : tqdm\n An instance of tqdm to update as the download progresses.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_270download_progress_hook = {"download_progress_hook", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_270download_progress_hook, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_269download_progress_hook}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_270download_progress_hook(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_t = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("download_progress_hook (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_t,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_t)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8352, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "download_progress_hook") < 0)) __PYX_ERR(0, 8352, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_t = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("download_progress_hook", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 8352, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.download_progress_hook", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_269download_progress_hook(__pyx_self, __pyx_v_t); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_269download_progress_hook(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_t) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook *__pyx_cur_scope; PyObject *__pyx_v_update_to = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__311) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 8352, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("download_progress_hook", __pyx_f[0], 8352, 0, __PYX_ERR(0, 8352, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_t = __pyx_v_t; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_t); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_t); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("gofast.tools.coreutils.download_progress_hook", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_update_to); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__541 = PyTuple_Pack(4, __pyx_n_s_t, __pyx_n_s_last_b, __pyx_n_s_update_to, __pyx_n_s_update_to); if (unlikely(!__pyx_tuple__541)) __PYX_ERR(0, 8352, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__541); __Pyx_GIVEREF(__pyx_tuple__541); /* … */ __Pyx_TraceLine(8352,0,__PYX_ERR(0, 8352, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_270download_progress_hook, 0, __pyx_n_s_download_progress_hook, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__311)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_d, __pyx_n_s_download_progress_hook, __pyx_t_8) < 0) __PYX_ERR(0, 8352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__311 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__541, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_download_progress_hook, 8352, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__311)) __PYX_ERR(0, 8352, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook { PyObject_HEAD PyObject *__pyx_v_last_b; PyObject *__pyx_v_t; };
8353: """
8354: Hook to update the tqdm progress bar during a download.
8355:
8356: Parameters
8357: ----------
8358: t : tqdm
8359: An instance of tqdm to update as the download progresses.
8360: """
+8361: last_b = [0]
__Pyx_TraceLine(8361,0,__PYX_ERR(0, 8361, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8361, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_int_0); __Pyx_GIVEREF(__pyx_int_0); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_int_0)) __PYX_ERR(0, 8361, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_last_b = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
8362:
+8363: def update_to(b=1, bsize=1, tsize=None):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22download_progress_hook_1update_to(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_22download_progress_hook_update_to, "\n Updates the progress bar.\n\n Parameters\n ----------\n b : int\n Number of blocks transferred so far [default: 1].\n bsize : int\n Size of each block (in tqdm-compatible units) [default: 1].\n tsize : int, optional\n Total size (in tqdm-compatible units). If None, remains unchanged.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_22download_progress_hook_1update_to = {"update_to", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_22download_progress_hook_1update_to, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_22download_progress_hook_update_to}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_22download_progress_hook_1update_to(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_b = 0; PyObject *__pyx_v_bsize = 0; PyObject *__pyx_v_tsize = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("update_to (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_b,&__pyx_n_s_bsize,&__pyx_n_s_tsize,0}; PyObject* values[3] = {0,0,0}; values[0] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_1))); values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_1))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_b); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8363, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_bsize); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8363, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_tsize); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8363, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "update_to") < 0)) __PYX_ERR(0, 8363, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_b = values[0]; __pyx_v_bsize = values[1]; __pyx_v_tsize = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("update_to", 0, 0, 3, __pyx_nargs); __PYX_ERR(0, 8363, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.download_progress_hook.update_to", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_22download_progress_hook_update_to(__pyx_self, __pyx_v_b, __pyx_v_bsize, __pyx_v_tsize); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_22download_progress_hook_update_to(PyObject *__pyx_self, PyObject *__pyx_v_b, PyObject *__pyx_v_bsize, PyObject *__pyx_v_tsize) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook *__pyx_cur_scope; struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook *__pyx_outer_scope; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_33_download_progress_hook *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_TraceCall("update_to", __pyx_f[0], 8363, 0, __PYX_ERR(0, 8363, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("gofast.tools.coreutils.download_progress_hook.update_to", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__312 = PyTuple_Pack(3, __pyx_n_s_b, __pyx_n_s_bsize, __pyx_n_s_tsize); if (unlikely(!__pyx_tuple__312)) __PYX_ERR(0, 8363, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__312); __Pyx_GIVEREF(__pyx_tuple__312); __pyx_codeobj__313 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__312, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_update_to, 8363, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__313)) __PYX_ERR(0, 8363, __pyx_L1_error) /* … */ __Pyx_TraceLine(8363,0,__PYX_ERR(0, 8363, __pyx_L1_error)) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_22download_progress_hook_1update_to, 0, __pyx_n_s_download_progress_hook_locals_up, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__313)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8363, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_tuple__314); __pyx_v_update_to = __pyx_t_1; __pyx_t_1 = 0; __pyx_tuple__314 = PyTuple_Pack(3, ((PyObject *)__pyx_int_1), ((PyObject *)__pyx_int_1), Py_None); if (unlikely(!__pyx_tuple__314)) __PYX_ERR(0, 8363, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__314); __Pyx_GIVEREF(__pyx_tuple__314);
8364: """
8365: Updates the progress bar.
8366:
8367: Parameters
8368: ----------
8369: b : int
8370: Number of blocks transferred so far [default: 1].
8371: bsize : int
8372: Size of each block (in tqdm-compatible units) [default: 1].
8373: tsize : int, optional
8374: Total size (in tqdm-compatible units). If None, remains unchanged.
8375: """
+8376: if tsize is not None:
__Pyx_TraceLine(8376,0,__PYX_ERR(0, 8376, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_tsize != Py_None); if (__pyx_t_1) { /* … */ }
+8377: t.total = tsize
__Pyx_TraceLine(8377,0,__PYX_ERR(0, 8377, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_t)) { __Pyx_RaiseClosureNameError("t"); __PYX_ERR(0, 8377, __pyx_L1_error) } if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_t, __pyx_n_s_total, __pyx_v_tsize) < 0) __PYX_ERR(0, 8377, __pyx_L1_error)
+8378: t.update((b - last_b[0]) * bsize)
__Pyx_TraceLine(8378,0,__PYX_ERR(0, 8378, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_t)) { __Pyx_RaiseClosureNameError("t"); __PYX_ERR(0, 8378, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_t, __pyx_n_s_update); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_cur_scope->__pyx_v_last_b)) { __Pyx_RaiseClosureNameError("last_b"); __PYX_ERR(0, 8378, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_last_b == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 8378, __pyx_L1_error) } __pyx_t_4 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_v_last_b, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = PyNumber_Subtract(__pyx_v_b, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyNumber_Multiply(__pyx_t_5, __pyx_v_bsize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+8379: last_b[0] = b
__Pyx_TraceLine(8379,0,__PYX_ERR(0, 8379, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_last_b)) { __Pyx_RaiseClosureNameError("last_b"); __PYX_ERR(0, 8379, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_last_b == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 8379, __pyx_L1_error) } if (unlikely((__Pyx_SetItemInt(__pyx_cur_scope->__pyx_v_last_b, 0, __pyx_v_b, long, 1, __Pyx_PyInt_From_long, 1, 0, 1) < 0))) __PYX_ERR(0, 8379, __pyx_L1_error)
8380:
+8381: return update_to
__Pyx_TraceLine(8381,0,__PYX_ERR(0, 8381, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_update_to); __pyx_r = __pyx_v_update_to; goto __pyx_L0;
8382:
+8383: def squeeze_specific_dim(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_272squeeze_specific_dim(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_271squeeze_specific_dim, "\n Squeeze specific dimensions of a NumPy array based on the axis parameter.\n \n This function provides a flexible way to remove single-dimensional entries\n from the shape of an array. By default, it targets the last dimension,\n but can be configured to squeeze any specified dimension or all single-dimension\n axes if `axis` is set to None.\n\n Parameters\n ----------\n arr : np.ndarray\n The input array to potentially squeeze.\n axis : Optional[int], default -1\n The specific axis to squeeze. If the size of this axis is 1, it will be\n removed from the array. If `axis` is None, all single-dimension axes are\n squeezed. If `axis` is set to a specific dimension (0, 1, ..., arr.ndim-1),\n only that dimension will be squeezed if its size is 1.\n\n Returns\n -------\n np.ndarray\n The array with the specified dimension squeezed if its size was 1,\n otherwise the original array. If `axis` is None, all single-dimension\n axes are squeezed.\n\n Examples\n --------\n Squeeze the last dimension:\n\n >>> from gofast.tools.coreutils import squeeze_specific_dim\n >>> arr = np.array([[1], [2], [3]])\n >>> print(squeeze_specific_dim(arr).shape)\n (3,)\n\n Squeeze all single-dimension axes:\n\n >>> arr = np.array([[[1], [2], [3]]])\n >>> print(squeeze_specific_dim(arr, None).shape)\n (3,)\n\n Squeeze a specific dimension (e.g., first dimension of a 3D array):\n\n >>> arr = np.array([[[1, 2, 3]]])\n >>> print(squeeze_specific_dim(arr, 0).shape)\n ([[1, 2, 3]])\n\n Not squeezing if the specified axis does not have size 1:\n\n >>> arr = np.array([[1, 2, 3], [4, 5, 6]])\n >>> print(squeeze_specific_dim(arr, 0).shape)\n [[1, 2, 3], [4, 5, 6]]\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_272squeeze_specific_dim = {"squeeze_specific_dim", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_272squeeze_specific_dim, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_271squeeze_specific_dim}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_272squeeze_specific_dim(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; PyObject *__pyx_v_axis = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("squeeze_specific_dim (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,&__pyx_n_s_axis,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_neg_1))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8383, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_axis); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8383, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "squeeze_specific_dim") < 0)) __PYX_ERR(0, 8383, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_arr = values[0]; __pyx_v_axis = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("squeeze_specific_dim", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 8383, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.squeeze_specific_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_271squeeze_specific_dim(__pyx_self, __pyx_v_arr, __pyx_v_axis); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_271squeeze_specific_dim(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr, PyObject *__pyx_v_axis) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__315) __Pyx_TraceCall("squeeze_specific_dim", __pyx_f[0], 8383, 0, __PYX_ERR(0, 8383, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.squeeze_specific_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__542 = PyTuple_Pack(2, __pyx_n_s_arr, __pyx_n_s_axis); if (unlikely(!__pyx_tuple__542)) __PYX_ERR(0, 8383, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__542); __Pyx_GIVEREF(__pyx_tuple__542); __pyx_codeobj__315 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__542, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_squeeze_specific_dim, 8383, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__315)) __PYX_ERR(0, 8383, __pyx_L1_error) /* … */ __Pyx_TraceLine(8383,0,__PYX_ERR(0, 8383, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_arr, __pyx_kp_s_np_ndarray) < 0) __PYX_ERR(0, 8383, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_axis, __pyx_kp_s_Optional_int) < 0) __PYX_ERR(0, 8383, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_kp_s_np_ndarray) < 0) __PYX_ERR(0, 8383, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_272squeeze_specific_dim, 0, __pyx_n_s_squeeze_specific_dim, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__315)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8383, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__543); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_squeeze_specific_dim, __pyx_t_5) < 0) __PYX_ERR(0, 8383, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__543 = PyTuple_Pack(1, ((PyObject *)__pyx_int_neg_1)); if (unlikely(!__pyx_tuple__543)) __PYX_ERR(0, 8383, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__543); __Pyx_GIVEREF(__pyx_tuple__543);
8384: arr: np.ndarray, axis: Optional[int] = -1
8385: ) -> np.ndarray:
8386: """
8387: Squeeze specific dimensions of a NumPy array based on the axis parameter.
8388:
8389: This function provides a flexible way to remove single-dimensional entries
8390: from the shape of an array. By default, it targets the last dimension,
8391: but can be configured to squeeze any specified dimension or all single-dimension
8392: axes if `axis` is set to None.
8393:
8394: Parameters
8395: ----------
8396: arr : np.ndarray
8397: The input array to potentially squeeze.
8398: axis : Optional[int], default -1
8399: The specific axis to squeeze. If the size of this axis is 1, it will be
8400: removed from the array. If `axis` is None, all single-dimension axes are
8401: squeezed. If `axis` is set to a specific dimension (0, 1, ..., arr.ndim-1),
8402: only that dimension will be squeezed if its size is 1.
8403:
8404: Returns
8405: -------
8406: np.ndarray
8407: The array with the specified dimension squeezed if its size was 1,
8408: otherwise the original array. If `axis` is None, all single-dimension
8409: axes are squeezed.
8410:
8411: Examples
8412: --------
8413: Squeeze the last dimension:
8414:
8415: >>> from gofast.tools.coreutils import squeeze_specific_dim
8416: >>> arr = np.array([[1], [2], [3]])
8417: >>> print(squeeze_specific_dim(arr).shape)
8418: (3,)
8419:
8420: Squeeze all single-dimension axes:
8421:
8422: >>> arr = np.array([[[1], [2], [3]]])
8423: >>> print(squeeze_specific_dim(arr, None).shape)
8424: (3,)
8425:
8426: Squeeze a specific dimension (e.g., first dimension of a 3D array):
8427:
8428: >>> arr = np.array([[[1, 2, 3]]])
8429: >>> print(squeeze_specific_dim(arr, 0).shape)
8430: ([[1, 2, 3]])
8431:
8432: Not squeezing if the specified axis does not have size 1:
8433:
8434: >>> arr = np.array([[1, 2, 3], [4, 5, 6]])
8435: >>> print(squeeze_specific_dim(arr, 0).shape)
8436: [[1, 2, 3], [4, 5, 6]]
8437: """
+8438: if axis is None:
__Pyx_TraceLine(8438,0,__PYX_ERR(0, 8438, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_axis == Py_None); if (__pyx_t_1) { /* … */ }
8439: # Squeeze all single-dimension axes
+8440: return np.squeeze(arr)
__Pyx_TraceLine(8440,0,__PYX_ERR(0, 8440, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_squeeze); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_arr}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 1+__pyx_t_5); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
8441: else:
8442: # Check if the specified axis is a single-dimension axis and squeeze it
+8443: try:
__Pyx_TraceLine(8443,0,__PYX_ERR(0, 8443, __pyx_L1_error)) /*else*/ { { /*try:*/ { /* … */ } __pyx_L4_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L6_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L8_try_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; __pyx_L7_except_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; } }
+8444: return np.squeeze(arr, axis=axis)
__Pyx_TraceLine(8444,0,__PYX_ERR(0, 8444, __pyx_L4_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8444, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_squeeze); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8444, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8444, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_arr); __Pyx_GIVEREF(__pyx_v_arr); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_arr)) __PYX_ERR(0, 8444, __pyx_L4_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8444, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_v_axis) < 0) __PYX_ERR(0, 8444, __pyx_L4_error) __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8444, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_9; __pyx_t_9 = 0; goto __pyx_L8_try_return;
+8445: except ValueError:
__Pyx_TraceLine(8445,0,__PYX_ERR(0, 8445, __pyx_L6_except_error)) __pyx_t_5 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_5) { __Pyx_AddTraceback("gofast.tools.coreutils.squeeze_specific_dim", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 8445, __pyx_L6_except_error) __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_2);
8446: # Return the array unchanged if squeezing is not applicable
+8447: return arr
__Pyx_TraceLine(8447,0,__PYX_ERR(0, 8447, __pyx_L6_except_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arr); __pyx_r = __pyx_v_arr; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_except_return; } goto __pyx_L6_except_error;
8448:
+8449: def contains_delimiter(s: str, delimiters: Union[str, list, set]) -> bool:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_274contains_delimiter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_273contains_delimiter, "\n Checks if the given string contains any of the specified delimiters.\n\n Parameters\n ----------\n s : str\n The string to check.\n delimiters : str, list, or set\n Delimiters to check for in the string. Can be specified as a single\n string (for a single delimiter), a list of strings, or a set of strings.\n\n Returns\n -------\n bool\n True if the string contains any of the delimiters, False otherwise.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import contains_delimiter\n >>> contains_delimiter(\"example__string\", \"__\")\n True\n\n >>> contains_delimiter(\"example--string\", [\"__\", \"--\", \"&\", \"@\", \"!\"])\n True\n\n >>> contains_delimiter(\"example&string\", {\"__\", \"--\", \"&\", \"@\", \"!\"})\n True\n\n >>> contains_delimiter(\"example@string\", \"__--&@!\")\n True\n\n >>> contains_delimiter(\"example_string\", {\"__\", \"--\", \"&\", \"@\", \"!\"})\n False\n\n >>> contains_delimiter(\"example#string\", \"#$%\")\n True\n\n >>> contains_delimiter(\"example$string\", [\"#\", \"$\", \"%\"])\n True\n\n >>> contains_delimiter(\"example%string\", \"#$%\")\n True\n\n >>> contains_delimiter(\"example^string\", [\"#\", \"$\", \"%\"])\n False\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_274contains_delimiter = {"contains_delimiter", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_274contains_delimiter, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_273contains_delimiter}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_274contains_delimiter(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_s = 0; PyObject *__pyx_v_delimiters = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("contains_delimiter (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_s_2,&__pyx_n_s_delimiters,0}; PyObject* values[2] = {0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_s_2)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8449, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_delimiters)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8449, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("contains_delimiter", 1, 2, 2, 1); __PYX_ERR(0, 8449, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "contains_delimiter") < 0)) __PYX_ERR(0, 8449, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); } __pyx_v_s = ((PyObject*)values[0]); __pyx_v_delimiters = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("contains_delimiter", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 8449, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.contains_delimiter", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_s), (&PyUnicode_Type), 0, "s", 1))) __PYX_ERR(0, 8449, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_273contains_delimiter(__pyx_self, __pyx_v_s, __pyx_v_delimiters); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_18contains_delimiter_2generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_273contains_delimiter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s, PyObject *__pyx_v_delimiters) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter *__pyx_cur_scope; PyObject *__pyx_gb_6gofast_5tools_9coreutils_18contains_delimiter_2generator12 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__316) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 8449, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("contains_delimiter", __pyx_f[0], 8449, 0, __PYX_ERR(0, 8449, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_s = __pyx_v_s; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_s); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_s); __Pyx_INCREF(__pyx_v_delimiters); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("gofast.tools.coreutils.contains_delimiter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_18contains_delimiter_2generator12); __Pyx_XDECREF(__pyx_v_delimiters); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__544 = PyTuple_Pack(4, __pyx_n_s_s_2, __pyx_n_s_delimiters, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__544)) __PYX_ERR(0, 8449, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__544); __Pyx_GIVEREF(__pyx_tuple__544); /* … */ __Pyx_TraceLine(8449,0,__PYX_ERR(0, 8449, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_s_2, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 8449, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_delimiters, __pyx_kp_s_Union_str_list_set) < 0) __PYX_ERR(0, 8449, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8449, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_274contains_delimiter, 0, __pyx_n_s_contains_delimiter, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__316)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8449, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_contains_delimiter, __pyx_t_8) < 0) __PYX_ERR(0, 8449, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__316 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__544, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_contains_delimiter, 8449, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__316)) __PYX_ERR(0, 8449, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter { PyObject_HEAD PyObject *__pyx_v_s; };
8450: """
8451: Checks if the given string contains any of the specified delimiters.
8452:
8453: Parameters
8454: ----------
8455: s : str
8456: The string to check.
8457: delimiters : str, list, or set
8458: Delimiters to check for in the string. Can be specified as a single
8459: string (for a single delimiter), a list of strings, or a set of strings.
8460:
8461: Returns
8462: -------
8463: bool
8464: True if the string contains any of the delimiters, False otherwise.
8465:
8466: Examples
8467: --------
8468: >>> from gofast.tools.coreutils import contains_delimiter
8469: >>> contains_delimiter("example__string", "__")
8470: True
8471:
8472: >>> contains_delimiter("example--string", ["__", "--", "&", "@", "!"])
8473: True
8474:
8475: >>> contains_delimiter("example&string", {"__", "--", "&", "@", "!"})
8476: True
8477:
8478: >>> contains_delimiter("example@string", "__--&@!")
8479: True
8480:
8481: >>> contains_delimiter("example_string", {"__", "--", "&", "@", "!"})
8482: False
8483:
8484: >>> contains_delimiter("example#string", "#$%")
8485: True
8486:
8487: >>> contains_delimiter("example$string", ["#", "$", "%"])
8488: True
8489:
8490: >>> contains_delimiter("example%string", "#$%")
8491: True
8492:
8493: >>> contains_delimiter("example^string", ["#", "$", "%"])
8494: False
8495: """
8496: # for consistency
+8497: s = str(s)
__Pyx_TraceLine(8497,0,__PYX_ERR(0, 8497, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Str(__pyx_cur_scope->__pyx_v_s); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8497, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_s); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_s, ((PyObject*)__pyx_t_1)); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
8498: # Convert delimiters to a set if it's not already a set
+8499: if not isinstance(delimiters, set):
__Pyx_TraceLine(8499,0,__PYX_ERR(0, 8499, __pyx_L1_error)) __pyx_t_2 = PySet_Check(__pyx_v_delimiters); __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { /* … */ }
+8500: if isinstance(delimiters, str):
__Pyx_TraceLine(8500,0,__PYX_ERR(0, 8500, __pyx_L1_error)) __pyx_t_3 = PyUnicode_Check(__pyx_v_delimiters); if (__pyx_t_3) { /* … */ goto __pyx_L4; }
+8501: delimiters = set(delimiters)
__Pyx_TraceLine(8501,0,__PYX_ERR(0, 8501, __pyx_L1_error)) __pyx_t_1 = PySet_New(__pyx_v_delimiters); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_delimiters, __pyx_t_1); __pyx_t_1 = 0;
8502: else: # Assuming it's a list or similar iterable
+8503: delimiters = set(delimiters)
__Pyx_TraceLine(8503,0,__PYX_ERR(0, 8503, __pyx_L1_error)) /*else*/ { __pyx_t_1 = PySet_New(__pyx_v_delimiters); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_delimiters, __pyx_t_1); __pyx_t_1 = 0; } __pyx_L4:;
8504:
+8505: return any(delimiter in s for delimiter in delimiters)
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18contains_delimiter_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_35_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_35_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_35_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_35_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_35_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 8505, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter *) __pyx_self;
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_18contains_delimiter_2generator12, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_contains_delimiter_locals_genexp, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 8505, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.contains_delimiter.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_18contains_delimiter_2generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 8505, __pyx_L1_error)
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 8505, __pyx_L1_error) }
if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
__pyx_t_3 = NULL;
} else {
__pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8505, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8505, __pyx_L1_error)
}
for (;;) {
if (likely(!__pyx_t_3)) {
if (likely(PyList_CheckExact(__pyx_t_1))) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8505, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 8505, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8505, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
} else {
{
Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8505, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 8505, __pyx_L1_error)
#else
__pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8505, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
#endif
}
} else {
__pyx_t_4 = __pyx_t_3(__pyx_t_1);
if (unlikely(!__pyx_t_4)) {
PyObject* exc_type = PyErr_Occurred();
if (exc_type) {
if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
else __PYX_ERR(0, 8505, __pyx_L1_error)
}
break;
}
__Pyx_GOTREF(__pyx_t_4);
}
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_delimiter);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_delimiter, __pyx_t_4);
__Pyx_GIVEREF(__pyx_t_4);
__pyx_t_4 = 0;
if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_s)) { __Pyx_RaiseClosureNameError("s"); __PYX_ERR(0, 8505, __pyx_L1_error) }
if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_s == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
__PYX_ERR(0, 8505, __pyx_L1_error)
}
__pyx_t_5 = (__Pyx_PyUnicode_ContainsTF(__pyx_cur_scope->__pyx_v_delimiter, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_s, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 8505, __pyx_L1_error)
if (__pyx_t_5) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/*else*/ {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(8505,0,__PYX_ERR(0, 8505, __pyx_L1_error))
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_18contains_delimiter_genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_delimiters); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8505, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_4 = __Pyx_Generator_Next(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8505, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_35_genexpr {
PyObject_HEAD
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_34_contains_delimiter *__pyx_outer_scope;
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_delimiter;
};
8506:
+8507: def convert_to_structured_format(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_276convert_to_structured_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_275convert_to_structured_format, "\n Converts input objects to structured numpy arrays or pandas DataFrame/Series\n based on their shapes and the `as_frame` flag. If conversion to a structured\n format fails, the original objects are returned. When `as_frame` is False,\n attempts are made to convert inputs to numpy arrays.\n \n Parameters\n ----------\n *arrays : Any\n A variable number of objects to potentially convert. These can be lists,\n tuples, or numpy arrays.\n as_frame : bool, default=True\n If True, attempts to convert arrays to DataFrame or Series; otherwise,\n attempts to standardize as numpy arrays.\n skip_sparse: bool, default=True \n Dont convert any sparse matrix and keept it as is. \n \n Returns\n -------\n List[Union[np.ndarray, pd.DataFrame, pd.Series]]\n A list containing the original objects, numpy arrays, DataFrames, or\n Series, depending on each object's structure and the `as_frame` flag.\n \n Examples\n --------\n Converting to pandas DataFrame/Series:\n >>> from gofast.tools.coreutils import convert_to_structured_format\n >>> import numpy as np \n >>> import pandas as pd \n >>> features= {\"feature_1\": range (7), \"feature_2\":['1', 2, 9, 35, \"0\", \"76\", 'r']}\n >>> target= pd.Series(data=range(10), name=\"target\")\n >>> convert_to_structured_format( features, target, as_frame=True)\n >>> arr1 = np.array([[1, 2, 3], [4, 5, 6]])\n >>> arr2 = np.array([7, 8, 9])\n >>> convert_to_structured_format(arr1, arr2, as_frame=True)\n [ DataFrame:\n 0 1 2\n 0 1 2 3\n 1 4 5 6,\n Series:\n 0 7\n 1 8\n 2 9\n ]\n\n Standardizing as numpy arrays:\n >>> list1 = [10, 11, 12]\n >>> tuple1 = (13, 14, 15)\n >>> convert_to_structured_format(list1, tuple1, as_frame=False)\n [ array([10, 11, 12]),\n array([13, 14, 15])\n ]\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_276convert_to_structured_format = {"convert_to_structured_format", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_276convert_to_structured_format, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_275convert_to_structured_format}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_276convert_to_structured_format(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_as_frame = 0; PyObject *__pyx_v_skip_sparse = 0; PyObject *__pyx_v_arrays = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("convert_to_structured_format (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_arrays = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_as_frame,&__pyx_n_s_skip_sparse,0}; PyObject* values[2] = {0,0}; /* … */ /* function exit code */ __Pyx_DECREF(__pyx_v_arrays); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_275convert_to_structured_format(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_as_frame, PyObject *__pyx_v_skip_sparse, PyObject *__pyx_v_arrays) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format *__pyx_cur_scope; PyObject *__pyx_v_attempt_conversion_to_numpy = 0; PyObject *__pyx_v_attempt_conversion_to_pandas = 0; PyObject *__pyx_9genexpr77__pyx_v_arr = NULL; PyObject *__pyx_9genexpr78__pyx_v_arr = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__317) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 8507, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("convert_to_structured_format", __pyx_f[0], 8507, 0, __PYX_ERR(0, 8507, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_skip_sparse = __pyx_v_skip_sparse; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_skip_sparse); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_skip_sparse); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_attempt_conversion_to_numpy); __Pyx_XDECREF(__pyx_v_attempt_conversion_to_pandas); __Pyx_XDECREF(__pyx_9genexpr77__pyx_v_arr); __Pyx_XDECREF(__pyx_9genexpr78__pyx_v_arr); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__545 = PyTuple_Pack(9, __pyx_n_s_as_frame, __pyx_n_s_skip_sparse, __pyx_n_s_arrays, __pyx_n_s_attempt_conversion_to_numpy, __pyx_n_s_attempt_conversion_to_numpy, __pyx_n_s_attempt_conversion_to_pandas, __pyx_n_s_attempt_conversion_to_pandas, __pyx_n_s_arr, __pyx_n_s_arr); if (unlikely(!__pyx_tuple__545)) __PYX_ERR(0, 8507, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__545); __Pyx_GIVEREF(__pyx_tuple__545); /* … */ __Pyx_TraceLine(8507,0,__PYX_ERR(0, 8507, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_as_frame, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_skip_sparse, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) __pyx_t_5 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_as_frame, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_skip_sparse, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_arrays, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_List_Union_ArrayLike_DataFrame_S) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_276convert_to_structured_format, 0, __pyx_n_s_convert_to_structured_format, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__317)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8507, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_4, __pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_convert_to_structured_format, __pyx_t_4) < 0) __PYX_ERR(0, 8507, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__317 = (PyObject*)__Pyx_PyCode_New(0, 0, 2, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__545, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_convert_to_structured_format, 8507, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__317)) __PYX_ERR(0, 8507, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format { PyObject_HEAD PyObject *__pyx_v_skip_sparse; };
+8508: *arrays: Any, as_frame: bool = True,
values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_True)));
+8509: skip_sparse: bool =True,
values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args > 0 && likely(kw_args <= 2)) { Py_ssize_t index; for (index = 0; index < 2 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8507, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "convert_to_structured_format") < 0)) __PYX_ERR(0, 8507, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_as_frame = values[0]; __pyx_v_skip_sparse = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("convert_to_structured_format", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 8507, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_arrays); __pyx_v_arrays = 0; __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_275convert_to_structured_format(__pyx_self, __pyx_v_as_frame, __pyx_v_skip_sparse, __pyx_v_arrays);
8510: ) -> List[Union[ArrayLike, DataFrame, Series]]:
8511: """
8512: Converts input objects to structured numpy arrays or pandas DataFrame/Series
8513: based on their shapes and the `as_frame` flag. If conversion to a structured
8514: format fails, the original objects are returned. When `as_frame` is False,
8515: attempts are made to convert inputs to numpy arrays.
8516:
8517: Parameters
8518: ----------
8519: *arrays : Any
8520: A variable number of objects to potentially convert. These can be lists,
8521: tuples, or numpy arrays.
8522: as_frame : bool, default=True
8523: If True, attempts to convert arrays to DataFrame or Series; otherwise,
8524: attempts to standardize as numpy arrays.
8525: skip_sparse: bool, default=True
8526: Dont convert any sparse matrix and keept it as is.
8527:
8528: Returns
8529: -------
8530: List[Union[np.ndarray, pd.DataFrame, pd.Series]]
8531: A list containing the original objects, numpy arrays, DataFrames, or
8532: Series, depending on each object's structure and the `as_frame` flag.
8533:
8534: Examples
8535: --------
8536: Converting to pandas DataFrame/Series:
8537: >>> from gofast.tools.coreutils import convert_to_structured_format
8538: >>> import numpy as np
8539: >>> import pandas as pd
8540: >>> features= {"feature_1": range (7), "feature_2":['1', 2, 9, 35, "0", "76", 'r']}
8541: >>> target= pd.Series(data=range(10), name="target")
8542: >>> convert_to_structured_format( features, target, as_frame=True)
8543: >>> arr1 = np.array([[1, 2, 3], [4, 5, 6]])
8544: >>> arr2 = np.array([7, 8, 9])
8545: >>> convert_to_structured_format(arr1, arr2, as_frame=True)
8546: [ DataFrame:
8547: 0 1 2
8548: 0 1 2 3
8549: 1 4 5 6,
8550: Series:
8551: 0 7
8552: 1 8
8553: 2 9
8554: ]
8555:
8556: Standardizing as numpy arrays:
8557: >>> list1 = [10, 11, 12]
8558: >>> tuple1 = (13, 14, 15)
8559: >>> convert_to_structured_format(list1, tuple1, as_frame=False)
8560: [ array([10, 11, 12]),
8561: array([13, 14, 15])
8562: ]
8563: """
8564:
+8565: def attempt_conversion_to_numpy(arr: Any) -> np.ndarray:
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_28convert_to_structured_format_1attempt_conversion_to_numpy(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_28convert_to_structured_format_attempt_conversion_to_numpy, "Attempts to convert an object to a numpy array."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_28convert_to_structured_format_1attempt_conversion_to_numpy = {"attempt_conversion_to_numpy", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_28convert_to_structured_format_1attempt_conversion_to_numpy, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_28convert_to_structured_format_attempt_conversion_to_numpy}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_28convert_to_structured_format_1attempt_conversion_to_numpy(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("attempt_conversion_to_numpy (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8565, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "attempt_conversion_to_numpy") < 0)) __PYX_ERR(0, 8565, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_arr = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("attempt_conversion_to_numpy", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 8565, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format.attempt_conversion_to_numpy", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_attempt_conversion_to_numpy(__pyx_self, __pyx_v_arr); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_attempt_conversion_to_numpy(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_arr) { PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceCall("attempt_conversion_to_numpy", __pyx_f[0], 8565, 0, __PYX_ERR(0, 8565, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format.attempt_conversion_to_numpy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__318 = PyTuple_Pack(1, __pyx_n_s_arr); if (unlikely(!__pyx_tuple__318)) __PYX_ERR(0, 8565, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__318); __Pyx_GIVEREF(__pyx_tuple__318); /* … */ __Pyx_TraceLine(8565,0,__PYX_ERR(0, 8565, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_arr, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8565, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_return, __pyx_kp_s_np_ndarray) < 0) __PYX_ERR(0, 8565, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_28convert_to_structured_format_1attempt_conversion_to_numpy, 0, __pyx_n_s_convert_to_structured_format_loc, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__319)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8565, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_attempt_conversion_to_numpy = __pyx_t_2; __pyx_t_2 = 0; __pyx_codeobj__319 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__318, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_attempt_conversion_to_numpy, 8565, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__319)) __PYX_ERR(0, 8565, __pyx_L1_error)
8566: """Attempts to convert an object to a numpy array."""
+8567: try:
__Pyx_TraceLine(8567,0,__PYX_ERR(0, 8567, __pyx_L1_error)) { /*try:*/ { /* … */ } __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; __pyx_L6_except_return:; __Pyx_XGIVEREF(__pyx_t_1); __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3); goto __pyx_L0; }
+8568: return np.array(arr)
__Pyx_TraceLine(8568,0,__PYX_ERR(0, 8568, __pyx_L3_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8568, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8568, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_arr}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8568, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_r = __pyx_t_4; __pyx_t_4 = 0; goto __pyx_L7_try_return;
+8569: except Exception:
__Pyx_TraceLine(8569,0,__PYX_ERR(0, 8569, __pyx_L5_except_error)) __pyx_t_7 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_7) { __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format.attempt_conversion_to_numpy", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 8569, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_5);
+8570: return arr
__Pyx_TraceLine(8570,0,__PYX_ERR(0, 8570, __pyx_L5_except_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arr); __pyx_r = __pyx_v_arr; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_except_return; } goto __pyx_L5_except_error;
8571:
+8572: def attempt_conversion_to_pandas(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_28convert_to_structured_format_3attempt_conversion_to_pandas(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_28convert_to_structured_format_2attempt_conversion_to_pandas, "Attempts to convert an array to a DataFrame or Series based on shape."); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_28convert_to_structured_format_3attempt_conversion_to_pandas = {"attempt_conversion_to_pandas", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_28convert_to_structured_format_3attempt_conversion_to_pandas, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_28convert_to_structured_format_2attempt_conversion_to_pandas}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_28convert_to_structured_format_3attempt_conversion_to_pandas(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_arr = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("attempt_conversion_to_pandas (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_arr,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_arr)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8572, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "attempt_conversion_to_pandas") < 0)) __PYX_ERR(0, 8572, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_arr = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("attempt_conversion_to_pandas", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 8572, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format.attempt_conversion_to_pandas", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_2attempt_conversion_to_pandas(__pyx_self, __pyx_v_arr); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_2attempt_conversion_to_pandas(PyObject *__pyx_self, PyObject *__pyx_v_arr) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format *__pyx_cur_scope; struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format *__pyx_outer_scope; PyObject *__pyx_v_issparse = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_36_convert_to_structured_format *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_TraceCall("attempt_conversion_to_pandas", __pyx_f[0], 8572, 0, __PYX_ERR(0, 8572, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.convert_to_structured_format.attempt_conversion_to_pandas", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_issparse); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__320 = PyTuple_Pack(2, __pyx_n_s_arr, __pyx_n_s_issparse); if (unlikely(!__pyx_tuple__320)) __PYX_ERR(0, 8572, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__320); __Pyx_GIVEREF(__pyx_tuple__320); /* … */ __Pyx_TraceLine(8572,0,__PYX_ERR(0, 8572, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_arr, __pyx_kp_s_np_ndarray) < 0) __PYX_ERR(0, 8572, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_kp_s_Union_np_ndarray_pd_DataFrame_pd) < 0) __PYX_ERR(0, 8572, __pyx_L1_error) __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_28convert_to_structured_format_3attempt_conversion_to_pandas, 0, __pyx_n_s_convert_to_structured_format_loc_2, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__321)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8572, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_1, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_attempt_conversion_to_pandas = __pyx_t_1; __pyx_t_1 = 0; __pyx_codeobj__321 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__320, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_attempt_conversion_to_pandas, 8572, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__321)) __PYX_ERR(0, 8572, __pyx_L1_error)
8573: arr: np.ndarray) -> Union[np.ndarray, pd.DataFrame, pd.Series]:
8574: """Attempts to convert an array to a DataFrame or Series based on shape."""
+8575: from scipy.sparse import issparse
__Pyx_TraceLine(8575,0,__PYX_ERR(0, 8575, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_issparse); __Pyx_GIVEREF(__pyx_n_s_issparse); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_issparse)) __PYX_ERR(0, 8575, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_scipy_sparse, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_issparse); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8575, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __pyx_v_issparse = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+8576: try:
__Pyx_TraceLine(8576,0,__PYX_ERR(0, 8576, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L1_error; __pyx_L7_try_return:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); goto __pyx_L0; __pyx_L4_exception_handled:; __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5); __pyx_L8_try_end:; }
+8577: if issparse(arr) and skip_sparse:
__Pyx_TraceLine(8577,0,__PYX_ERR(0, 8577, __pyx_L3_error)) __Pyx_INCREF(__pyx_v_issparse); __pyx_t_1 = __pyx_v_issparse; __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_arr}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8577, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 8577, __pyx_L3_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { } else { __pyx_t_6 = __pyx_t_9; goto __pyx_L10_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_skip_sparse)) { __Pyx_RaiseClosureNameError("skip_sparse"); __PYX_ERR(0, 8577, __pyx_L3_error) } __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_skip_sparse); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 8577, __pyx_L3_error) __pyx_t_6 = __pyx_t_9; __pyx_L10_bool_binop_done:; if (unlikely(__pyx_t_6)) { /* … */ }
+8578: raise # dont perform any convertion
__Pyx_TraceLine(8578,0,__PYX_ERR(0, 8578, __pyx_L3_error)) __Pyx_ReraiseException(); __PYX_ERR(0, 8578, __pyx_L3_error)
+8579: if hasattr(arr, '__array__'):
__Pyx_TraceLine(8579,0,__PYX_ERR(0, 8579, __pyx_L3_error)) __pyx_t_6 = __Pyx_HasAttr(__pyx_v_arr, __pyx_n_u_array_2); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 8579, __pyx_L3_error) if (__pyx_t_6) { /* … */ goto __pyx_L12; }
+8580: if arr.ndim == 1:
__Pyx_TraceLine(8580,0,__PYX_ERR(0, 8580, __pyx_L3_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8580, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 8580, __pyx_L3_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ }
+8581: return pd.Series(arr)
__Pyx_TraceLine(8581,0,__PYX_ERR(0, 8581, __pyx_L3_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8581, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_Series); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8581, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_arr}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8581, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L7_try_return;
+8582: elif arr.ndim == 2:
__Pyx_TraceLine(8582,0,__PYX_ERR(0, 8582, __pyx_L3_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_ndim); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8582, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_2, __pyx_int_2, 2, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 8582, __pyx_L3_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_6) { /* … */ }
+8583: if arr.shape[1] == 1:
__Pyx_TraceLine(8583,0,__PYX_ERR(0, 8583, __pyx_L3_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8583, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8583, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_6 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_7, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 8583, __pyx_L3_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_6) { /* … */ }
+8584: return pd.Series(arr.squeeze())
__Pyx_TraceLine(8584,0,__PYX_ERR(0, 8584, __pyx_L3_error)) __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8584, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Series); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8584, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_squeeze); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8584, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8584, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_10 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_2}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8584, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L7_try_return;
8585: else:
+8586: return pd.DataFrame(arr)
__Pyx_TraceLine(8586,0,__PYX_ERR(0, 8586, __pyx_L3_error)) /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8586, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8586, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_1)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_arr}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8586, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L7_try_return; }
8587: else:
+8588: return pd.DataFrame(arr)
__Pyx_TraceLine(8588,0,__PYX_ERR(0, 8588, __pyx_L3_error)) /*else*/ { __Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8588, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8588, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_1))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_1, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_arr}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_1, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8588, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } __pyx_r = __pyx_t_7; __pyx_t_7 = 0; goto __pyx_L7_try_return; } __pyx_L12:;
+8589: except Exception:
__Pyx_TraceLine(8589,0,__PYX_ERR(0, 8589, __pyx_L5_except_error)) __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_8) { __Pyx_ErrRestore(0,0,0); goto __pyx_L4_exception_handled; } goto __pyx_L5_except_error;
8590: pass
+8591: return arr
__Pyx_TraceLine(8591,0,__PYX_ERR(0, 8591, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_arr); __pyx_r = __pyx_v_arr; goto __pyx_L0;
8592:
+8593: if as_frame:
__Pyx_TraceLine(8593,0,__PYX_ERR(0, 8593, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_as_frame); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 8593, __pyx_L1_error) if (__pyx_t_3) { /* … */ }
+8594: return [attempt_conversion_to_pandas(arr) for arr in arrays]
__Pyx_TraceLine(8594,0,__PYX_ERR(0, 8594, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8594, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8594, __pyx_L6_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 8594, __pyx_L6_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8594, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_9genexpr77__pyx_v_arr, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_2attempt_conversion_to_pandas(__pyx_v_attempt_conversion_to_pandas, __pyx_9genexpr77__pyx_v_arr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8594, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 8594, __pyx_L6_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr77__pyx_v_arr); __pyx_9genexpr77__pyx_v_arr = 0; goto __pyx_L10_exit_scope; __pyx_L6_error:; __Pyx_XDECREF(__pyx_9genexpr77__pyx_v_arr); __pyx_9genexpr77__pyx_v_arr = 0; goto __pyx_L1_error; __pyx_L10_exit_scope:; } /* exit inner scope */ __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
8595: else:
8596: # Try to convert everything to numpy arrays, return as is if it fails
+8597: return [attempt_conversion_to_numpy(attempt_conversion_to_pandas(arr)
__Pyx_TraceLine(8597,0,__PYX_ERR(0, 8597, __pyx_L1_error)) /*else*/ { __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8597, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(8597,0,__PYX_ERR(0, 8597, __pyx_L13_error)) __pyx_t_5 = __pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_2attempt_conversion_to_pandas(__pyx_v_attempt_conversion_to_pandas, __pyx_9genexpr78__pyx_v_arr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8597, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __pyx_pf_6gofast_5tools_9coreutils_28convert_to_structured_format_attempt_conversion_to_numpy(__pyx_v_attempt_conversion_to_numpy, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8597, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 8597, __pyx_L13_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+8598: ) for arr in arrays]
__Pyx_TraceLine(8598,0,__PYX_ERR(0, 8598, __pyx_L13_error)) __pyx_t_2 = __pyx_v_arrays; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8598, __pyx_L13_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_5); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 8598, __pyx_L13_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8598, __pyx_L13_error) __Pyx_GOTREF(__pyx_t_5); #endif __Pyx_XDECREF_SET(__pyx_9genexpr78__pyx_v_arr, __pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(8598,0,__PYX_ERR(0, 8598, __pyx_L13_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr78__pyx_v_arr); __pyx_9genexpr78__pyx_v_arr = 0; goto __pyx_L17_exit_scope; __pyx_L13_error:; __Pyx_XDECREF(__pyx_9genexpr78__pyx_v_arr); __pyx_9genexpr78__pyx_v_arr = 0; goto __pyx_L1_error; __pyx_L17_exit_scope:; } /* exit inner scope */ __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
8599:
+8600: def resample_data(*data: Any, samples: Union[int, float, str] = 1,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_278resample_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_277resample_data, "\n Resample multiple data structures (arrays, sparse matrices, Series, DataFrames)\n based on specified sample size or ratio.\n\n Parameters\n ----------\n *data_structures : Any\n Variable number of array-like, sparse matrix, pandas Series, or DataFrame\n objects to be resampled.\n samples : int, float, or str, optional\n Number of items to sample or a ratio of items to sample (if < 1 or\n expressed as a percentage string, e.g., \"50%\"). Defaults to 1, meaning\n no resampling unless specified.\n replace : bool, default=False\n Whether sampling of the same row more than once is allowed.\n random_state : int, optional\n Seed for the random number generator for reproducibility.\n shuffle : bool, default=True\n Whether to shuffle data before sampling.\n\n Returns\n -------\n List[Any]\n A list of resampled data structures, matching the input order. Each\n structure is resampled according to the `samples` parameter.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import resample_data\n >>> from sklearn.datasets import load_iris\n >>> iris = load_iris(as_frame=True)\n >>> data, target = iris.data, iris.target\n >>> resampled_data, resampled_target = resample_data(data, target, samples=0.5,\n ... random_state=42)\n >>> print(resampled_data.shape, resampled_target.shape)\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_278resample_data = {"resample_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_278resample_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_277resample_data}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_278resample_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_samples = 0; PyObject *__pyx_v_replace = 0; PyObject *__pyx_v_random_state = 0; PyObject *__pyx_v_shuffle = 0; PyObject *__pyx_v_data = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("resample_data (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_data = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_samples,&__pyx_n_s_replace,&__pyx_n_s_random_state,&__pyx_n_s_shuffle,0}; PyObject* values[4] = {0,0,0,0}; values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)__pyx_int_1))); /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_data); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_277resample_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_samples, PyObject *__pyx_v_replace, PyObject *__pyx_v_random_state, PyObject *__pyx_v_shuffle, PyObject *__pyx_v_data) { PyObject *__pyx_v_resampled_structures = NULL; PyObject *__pyx_v_d = NULL; PyObject *__pyx_v_n_samples = NULL; PyObject *__pyx_v_sampled_d = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__322) __Pyx_TraceCall("resample_data", __pyx_f[0], 8600, 0, __PYX_ERR(0, 8600, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.resample_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_resampled_structures); __Pyx_XDECREF(__pyx_v_d); __Pyx_XDECREF(__pyx_v_n_samples); __Pyx_XDECREF(__pyx_v_sampled_d); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__546 = PyTuple_Pack(9, __pyx_n_s_samples, __pyx_n_s_replace, __pyx_n_s_random_state, __pyx_n_s_shuffle, __pyx_n_s_data, __pyx_n_s_resampled_structures, __pyx_n_s_d_3, __pyx_n_s_n_samples, __pyx_n_s_sampled_d); if (unlikely(!__pyx_tuple__546)) __PYX_ERR(0, 8600, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__546); __Pyx_GIVEREF(__pyx_tuple__546); /* … */ __Pyx_TraceLine(8600,0,__PYX_ERR(0, 8600, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_samples, ((PyObject *)__pyx_int_1)) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_replace, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) /* … */ __Pyx_TraceLine(8600,0,__PYX_ERR(0, 8600, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_samples, __pyx_kp_s_Union_int_float_str) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_replace, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_random_state, __pyx_n_s_int) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_shuffle, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_data, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_List_Any) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_278resample_data, 0, __pyx_n_s_resample_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__322)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8600, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_8, __pyx_t_4); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_resample_data, __pyx_t_8) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__322 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__546, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_resample_data, 8600, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__322)) __PYX_ERR(0, 8600, __pyx_L1_error)
+8601: replace: bool = False, random_state: int = None,
values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)Py_None)); /* … */ __Pyx_TraceLine(8601,0,__PYX_ERR(0, 8601, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_random_state, Py_None) < 0) __PYX_ERR(0, 8600, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_shuffle, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 8600, __pyx_L1_error)
+8602: shuffle: bool = True) -> List[Any]:
values[3] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args > 0 && likely(kw_args <= 4)) { Py_ssize_t index; for (index = 0; index < 4 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8600, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "resample_data") < 0)) __PYX_ERR(0, 8600, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_samples = values[0]; __pyx_v_replace = values[1]; __pyx_v_random_state = ((PyObject*)values[2]); __pyx_v_shuffle = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("resample_data", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 8600, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_data); __pyx_v_data = 0; __Pyx_AddTraceback("gofast.tools.coreutils.resample_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_random_state), (&PyInt_Type), 1, "random_state", 1))) __PYX_ERR(0, 8601, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_277resample_data(__pyx_self, __pyx_v_samples, __pyx_v_replace, __pyx_v_random_state, __pyx_v_shuffle, __pyx_v_data);
8603: """
8604: Resample multiple data structures (arrays, sparse matrices, Series, DataFrames)
8605: based on specified sample size or ratio.
8606:
8607: Parameters
8608: ----------
8609: *data_structures : Any
8610: Variable number of array-like, sparse matrix, pandas Series, or DataFrame
8611: objects to be resampled.
8612: samples : int, float, or str, optional
8613: Number of items to sample or a ratio of items to sample (if < 1 or
8614: expressed as a percentage string, e.g., "50%"). Defaults to 1, meaning
8615: no resampling unless specified.
8616: replace : bool, default=False
8617: Whether sampling of the same row more than once is allowed.
8618: random_state : int, optional
8619: Seed for the random number generator for reproducibility.
8620: shuffle : bool, default=True
8621: Whether to shuffle data before sampling.
8622:
8623: Returns
8624: -------
8625: List[Any]
8626: A list of resampled data structures, matching the input order. Each
8627: structure is resampled according to the `samples` parameter.
8628:
8629: Examples
8630: --------
8631: >>> from gofast.tools.coreutils import resample_data
8632: >>> from sklearn.datasets import load_iris
8633: >>> iris = load_iris(as_frame=True)
8634: >>> data, target = iris.data, iris.target
8635: >>> resampled_data, resampled_target = resample_data(data, target, samples=0.5,
8636: ... random_state=42)
8637: >>> print(resampled_data.shape, resampled_target.shape)
8638: """
+8639: resampled_structures = []
__Pyx_TraceLine(8639,0,__PYX_ERR(0, 8639, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8639, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_resampled_structures = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
8640:
+8641: for d in data:
__Pyx_TraceLine(8641,0,__PYX_ERR(0, 8641, __pyx_L1_error)) __pyx_t_1 = __pyx_v_data; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8641, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 8641, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8641, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_d, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(8641,0,__PYX_ERR(0, 8641, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8642: # Correct way to access the shape of the sparse matrix
8643: # encapsulated in a numpy array
+8644: try:
__Pyx_TraceLine(8644,0,__PYX_ERR(0, 8644, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L12_try_end; __pyx_L5_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ __pyx_L7_except_error:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); goto __pyx_L1_error; __pyx_L6_exception_handled:; __Pyx_XGIVEREF(__pyx_t_4); __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6); __pyx_L12_try_end:; }
+8645: if d.dtype == object and scipy.sparse.issparse(d.item()):
__Pyx_TraceLine(8645,0,__PYX_ERR(0, 8645, __pyx_L5_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_dtype); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_builtin_object, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_9) { } else { __pyx_t_7 = __pyx_t_9; goto __pyx_L14_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_scipy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sparse); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_issparse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_item); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_10 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_13, 0+__pyx_t_13); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_11 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_t_10}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 8645, __pyx_L5_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_7 = __pyx_t_9; __pyx_L14_bool_binop_done:; if (__pyx_t_7) { /* … */ }
+8646: d = d.item() # Access the sparse matrix
__Pyx_TraceLine(8646,0,__PYX_ERR(0, 8646, __pyx_L5_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_item); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8646, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_13, 0+__pyx_t_13); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8646, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_8); __pyx_t_8 = 0;
8647: # Now you can safely access the number of rows
+8648: except:
__Pyx_TraceLine(8648,0,__PYX_ERR(0, 8648, __pyx_L7_except_error)) /*except:*/ { __Pyx_ErrRestore(0,0,0); goto __pyx_L6_exception_handled; }
8649: # Fallback for regular numpy arrays/data or
8650: # directly accessible sparse matrices
8651: pass
+8652: n_samples = _determine_sample_size(d, samples, is_percent="%" in str(samples))
__Pyx_TraceLine(8652,0,__PYX_ERR(0, 8652, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_determine_sample_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_d); __Pyx_GIVEREF(__pyx_v_d); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_d)) __PYX_ERR(0, 8652, __pyx_L1_error); __Pyx_INCREF(__pyx_v_samples); __Pyx_GIVEREF(__pyx_v_samples); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_samples)) __PYX_ERR(0, 8652, __pyx_L1_error); __pyx_t_10 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_Str(__pyx_v_samples); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_7 = (__Pyx_PyUnicode_ContainsTF(__pyx_kp_u__203, __pyx_t_11, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyBool_FromLong(__pyx_t_7); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_is_percent, __pyx_t_11) < 0) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8652, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_n_samples, __pyx_t_11); __pyx_t_11 = 0;
+8653: sampled_d = _perform_sampling(d, n_samples, replace, random_state, shuffle)
__Pyx_TraceLine(8653,0,__PYX_ERR(0, 8653, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_perform_sampling); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_3 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_v_d, __pyx_v_n_samples, __pyx_v_replace, __pyx_v_random_state, __pyx_v_shuffle}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_13, 5+__pyx_t_13); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8653, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_XDECREF_SET(__pyx_v_sampled_d, __pyx_t_11); __pyx_t_11 = 0;
+8654: resampled_structures.append(sampled_d)
__Pyx_TraceLine(8654,0,__PYX_ERR(0, 8654, __pyx_L1_error)) __pyx_t_14 = __Pyx_PyList_Append(__pyx_v_resampled_structures, __pyx_v_sampled_d); if (unlikely(__pyx_t_14 == ((int)-1))) __PYX_ERR(0, 8654, __pyx_L1_error)
8655:
+8656: return resampled_structures
__Pyx_TraceLine(8656,0,__PYX_ERR(0, 8656, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_resampled_structures); __pyx_r = __pyx_v_resampled_structures; goto __pyx_L0;
8657:
+8658: def _determine_sample_size(d: Any, samples: Union[int, float, str],
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_280_determine_sample_size(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_279_determine_sample_size, "\n Determine the number of samples to draw based on the input size or ratio.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_280_determine_sample_size = {"_determine_sample_size", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_280_determine_sample_size, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_279_determine_sample_size}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_280_determine_sample_size(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_samples = 0; PyObject *__pyx_v_is_percent = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_determine_sample_size (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_samples,&__pyx_n_s_is_percent,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8658, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_samples)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8658, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_determine_sample_size", 1, 3, 3, 1); __PYX_ERR(0, 8658, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_is_percent)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8658, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_determine_sample_size", 1, 3, 3, 2); __PYX_ERR(0, 8658, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_determine_sample_size") < 0)) __PYX_ERR(0, 8658, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_d = values[0]; __pyx_v_samples = values[1]; __pyx_v_is_percent = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_determine_sample_size", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 8658, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._determine_sample_size", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_279_determine_sample_size(__pyx_self, __pyx_v_d, __pyx_v_samples, __pyx_v_is_percent); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_279_determine_sample_size(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_samples, PyObject *__pyx_v_is_percent) { PyObject *__pyx_v_d_length = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__323) __Pyx_TraceCall("_determine_sample_size", __pyx_f[0], 8658, 0, __PYX_ERR(0, 8658, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_samples); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_13); __Pyx_XDECREF(__pyx_t_14); __Pyx_AddTraceback("gofast.tools.coreutils._determine_sample_size", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_d_length); __Pyx_XDECREF(__pyx_v_samples); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__547 = PyTuple_Pack(4, __pyx_n_s_d_3, __pyx_n_s_samples, __pyx_n_s_is_percent, __pyx_n_s_d_length); if (unlikely(!__pyx_tuple__547)) __PYX_ERR(0, 8658, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__547); __Pyx_GIVEREF(__pyx_tuple__547); /* … */ __Pyx_TraceLine(8658,0,__PYX_ERR(0, 8658, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_d_3, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8658, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_samples, __pyx_kp_s_Union_int_float_str) < 0) __PYX_ERR(0, 8658, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_is_percent, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8658, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_return, __pyx_n_s_int) < 0) __PYX_ERR(0, 8658, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_280_determine_sample_size, 0, __pyx_n_s_determine_sample_size, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__323)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8658, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_determine_sample_size, __pyx_t_5) < 0) __PYX_ERR(0, 8658, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__323 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__547, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_determine_sample_size, 8658, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__323)) __PYX_ERR(0, 8658, __pyx_L1_error)
8659: is_percent: bool) -> int:
8660: """
8661: Determine the number of samples to draw based on the input size or ratio.
8662: """
+8663: if isinstance(samples, str) and is_percent:
__Pyx_TraceLine(8663,0,__PYX_ERR(0, 8663, __pyx_L1_error)) __pyx_t_2 = PyUnicode_Check(__pyx_v_samples); if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_is_percent); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8663, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+8664: samples = samples.replace("%", "")
__Pyx_TraceLine(8664,0,__PYX_ERR(0, 8664, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_samples, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__204, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_samples, __pyx_t_4); __pyx_t_4 = 0;
+8665: try:
__Pyx_TraceLine(8665,0,__PYX_ERR(0, 8665, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L11_try_end; __pyx_L6_error:; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __pyx_L8_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L11_try_end:; }
+8666: samples = float(samples)
__Pyx_TraceLine(8666,0,__PYX_ERR(0, 8666, __pyx_L6_error)) __pyx_t_4 = __Pyx_PyNumber_Float(__pyx_v_samples); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8666, __pyx_L6_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF_SET(__pyx_v_samples, __pyx_t_4); __pyx_t_4 = 0;
+8667: except ValueError:
__Pyx_TraceLine(8667,0,__PYX_ERR(0, 8667, __pyx_L8_except_error)) __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_8) { __Pyx_AddTraceback("gofast.tools.coreutils._determine_sample_size", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_9) < 0) __PYX_ERR(0, 8667, __pyx_L8_except_error) __Pyx_XGOTREF(__pyx_t_4); __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_9);
+8668: raise TypeError(f"Invalid type for 'samples': {type(samples).__name__}."
__Pyx_TraceLine(8668,0,__PYX_ERR(0, 8668, __pyx_L8_except_error)) __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8668, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = 0; __pyx_t_12 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_type_for_samples); __pyx_t_11 += 28; __Pyx_GIVEREF(__pyx_kp_u_Invalid_type_for_samples); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_kp_u_Invalid_type_for_samples); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_v_samples)), __pyx_n_s_name); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8668, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_14 = __Pyx_PyObject_FormatSimple(__pyx_t_13, __pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8668, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_12 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) > __pyx_t_12) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_14) : __pyx_t_12; __pyx_t_11 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_14); __pyx_t_14 = 0; __Pyx_INCREF(__pyx_kp_u_Expected_int_float_or_percentag); __pyx_t_11 += 44; __Pyx_GIVEREF(__pyx_kp_u_Expected_int_float_or_percentag); PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_kp_u_Expected_int_float_or_percentag); __pyx_t_14 = __Pyx_PyUnicode_Join(__pyx_t_10, 3, __pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 8668, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8668, __pyx_L8_except_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_Raise(__pyx_t_10, 0, 0, 0); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __PYX_ERR(0, 8668, __pyx_L8_except_error) } goto __pyx_L8_except_error;
8669: " Expected int, float, or percentage string.")
8670:
+8671: d_length = d.shape[0] if hasattr(d, 'shape') else len(d)
__Pyx_TraceLine(8671,0,__PYX_ERR(0, 8671, __pyx_L1_error)) __pyx_t_1 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_shape); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 8671, __pyx_L1_error) if (__pyx_t_1) { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = __pyx_t_4; __pyx_t_4 = 0; } else { __pyx_t_11 = PyObject_Length(__pyx_v_d); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8671, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __pyx_t_4; __pyx_t_4 = 0; } __pyx_v_d_length = __pyx_t_9; __pyx_t_9 = 0;
+8672: if samples < 1 or is_percent:
__Pyx_TraceLine(8672,0,__PYX_ERR(0, 8672, __pyx_L1_error)) __pyx_t_9 = PyObject_RichCompare(__pyx_v_samples, __pyx_int_1, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8672, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8672, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_is_percent); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8672, __pyx_L1_error) __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+8673: return max(1, int(samples * d_length))
__Pyx_TraceLine(8673,0,__PYX_ERR(0, 8673, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_9 = PyNumber_Multiply(__pyx_v_samples, __pyx_v_d_length); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_15 = 1; __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = PyObject_RichCompare(__pyx_t_4, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_1) { __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = __pyx_t_4; } else { __pyx_t_10 = __Pyx_PyInt_From_long(__pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_9 = __pyx_t_10; __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_9))) __PYX_ERR(0, 8673, __pyx_L1_error) __Pyx_INCREF(__pyx_t_9); __pyx_r = ((PyObject*)__pyx_t_9); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L0;
+8674: return int(samples)
__Pyx_TraceLine(8674,0,__PYX_ERR(0, 8674, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_9 = __Pyx_PyNumber_Int(__pyx_v_samples); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8674, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_9)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_9))) __PYX_ERR(0, 8674, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L0;
8675:
+8676: def _perform_sampling(d: Any, n_samples: int, replace: bool,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_282_perform_sampling(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_281_perform_sampling, "\n Perform the actual sampling operation on the data structure.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_282_perform_sampling = {"_perform_sampling", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_282_perform_sampling, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_281_perform_sampling}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_282_perform_sampling(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_d = 0; PyObject *__pyx_v_n_samples = 0; PyObject *__pyx_v_replace = 0; PyObject *__pyx_v_random_state = 0; PyObject *__pyx_v_shuffle = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_perform_sampling (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_d_3,&__pyx_n_s_n_samples,&__pyx_n_s_replace,&__pyx_n_s_random_state,&__pyx_n_s_shuffle,0}; PyObject* values[5] = {0,0,0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_d_3)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8676, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n_samples)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8676, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_perform_sampling", 1, 5, 5, 1); __PYX_ERR(0, 8676, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_replace)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8676, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_perform_sampling", 1, 5, 5, 2); __PYX_ERR(0, 8676, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_random_state)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[3]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8676, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_perform_sampling", 1, 5, 5, 3); __PYX_ERR(0, 8676, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (likely((values[4] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_shuffle)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[4]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8676, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_perform_sampling", 1, 5, 5, 4); __PYX_ERR(0, 8676, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_perform_sampling") < 0)) __PYX_ERR(0, 8676, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 5)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); } __pyx_v_d = values[0]; __pyx_v_n_samples = ((PyObject*)values[1]); __pyx_v_replace = values[2]; __pyx_v_random_state = ((PyObject*)values[3]); __pyx_v_shuffle = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_perform_sampling", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 8676, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils._perform_sampling", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_n_samples), (&PyInt_Type), 0, "n_samples", 1))) __PYX_ERR(0, 8676, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_random_state), (&PyInt_Type), 0, "random_state", 1))) __PYX_ERR(0, 8677, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_281_perform_sampling(__pyx_self, __pyx_v_d, __pyx_v_n_samples, __pyx_v_replace, __pyx_v_random_state, __pyx_v_shuffle); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_281_perform_sampling(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_d, PyObject *__pyx_v_n_samples, PyObject *__pyx_v_replace, PyObject *__pyx_v_random_state, PyObject *__pyx_v_shuffle) { PyObject *__pyx_v_indices = NULL; PyObject *__pyx_v_d_array = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__324) __Pyx_TraceCall("_perform_sampling", __pyx_f[0], 8676, 0, __PYX_ERR(0, 8676, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_d); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils._perform_sampling", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_indices); __Pyx_XDECREF(__pyx_v_d_array); __Pyx_XDECREF(__pyx_v_d); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__548 = PyTuple_Pack(7, __pyx_n_s_d_3, __pyx_n_s_n_samples, __pyx_n_s_replace, __pyx_n_s_random_state, __pyx_n_s_shuffle, __pyx_n_s_indices, __pyx_n_s_d_array); if (unlikely(!__pyx_tuple__548)) __PYX_ERR(0, 8676, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__548); __Pyx_GIVEREF(__pyx_tuple__548); /* … */ __Pyx_TraceLine(8676,0,__PYX_ERR(0, 8676, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_d_3, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_n_samples, __pyx_n_s_int) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_replace, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_random_state, __pyx_n_s_int) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_shuffle, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_282_perform_sampling, 0, __pyx_n_s_perform_sampling, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__324)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8676, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_perform_sampling, __pyx_t_8) < 0) __PYX_ERR(0, 8676, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__324 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__548, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_perform_sampling, 8676, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__324)) __PYX_ERR(0, 8676, __pyx_L1_error)
8677: random_state: int, shuffle: bool) -> Any:
8678: """
8679: Perform the actual sampling operation on the data structure.
8680: """
+8681: if isinstance(d, pd.DataFrame) or isinstance(d, pd.Series):
__Pyx_TraceLine(8681,0,__PYX_ERR(0, 8681, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_v_d, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 8681, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Series); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8681, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_v_d, __pyx_t_2); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 8681, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = __pyx_t_4; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+8682: return d.sample(n=n_samples, replace=replace, random_state=random_state
__Pyx_TraceLine(8682,0,__PYX_ERR(0, 8682, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); /* … */ __Pyx_TraceLine(8682,0,__PYX_ERR(0, 8682, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_sample); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_n, __pyx_v_n_samples) < 0) __PYX_ERR(0, 8682, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_replace, __pyx_v_replace) < 0) __PYX_ERR(0, 8682, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_random_state, __pyx_v_random_state) < 0) __PYX_ERR(0, 8682, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_empty_tuple, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8682, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_6; __pyx_t_6 = 0; } else {
+8683: ) if shuffle else d.iloc[:n_samples]
__Pyx_TraceLine(8683,0,__PYX_ERR(0, 8683, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8683, __pyx_L1_error) if (__pyx_t_1) { /* … */ __Pyx_TraceLine(8683,0,__PYX_ERR(0, 8683, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_iloc); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8683, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, 0, NULL, &__pyx_v_n_samples, NULL, 0, 0, 1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8683, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+8684: elif scipy.sparse.issparse(d):
__Pyx_TraceLine(8684,0,__PYX_ERR(0, 8684, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_scipy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sparse); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_issparse); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_d}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8684, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+8685: if scipy.sparse.isspmatrix_coo(d):
__Pyx_TraceLine(8685,0,__PYX_ERR(0, 8685, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_scipy); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sparse); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isspmatrix_coo); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_d}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8685, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8685, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ }
+8686: warnings.warn("coo_matrix does not support indexing. Conversion"
__Pyx_TraceLine(8686,0,__PYX_ERR(0, 8686, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_warnings); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_warn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_kp_u_coo_matrix_does_not_support_inde_2}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8686, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8687: " to CSR matrix is recommended.")
+8688: d = d.tocsr()
__Pyx_TraceLine(8688,0,__PYX_ERR(0, 8688, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_tocsr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8688, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF_SET(__pyx_v_d, __pyx_t_2); __pyx_t_2 = 0;
+8689: indices = np.random.choice(d.shape[0], n_samples, replace=replace
__Pyx_TraceLine(8689,0,__PYX_ERR(0, 8689, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_random); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_choice); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_d, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 8689, __pyx_L1_error); __Pyx_INCREF(__pyx_v_n_samples); __Pyx_GIVEREF(__pyx_v_n_samples); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_n_samples)) __PYX_ERR(0, 8689, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_replace, __pyx_v_replace) < 0) __PYX_ERR(0, 8689, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8689, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_8; __pyx_t_8 = 0; } else {
+8690: ) if shuffle else np.arange(n_samples)
__Pyx_TraceLine(8690,0,__PYX_ERR(0, 8690, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8690, __pyx_L1_error) if (__pyx_t_1) { /* … */ __Pyx_TraceLine(8690,0,__PYX_ERR(0, 8690, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_n_samples}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_2 = __pyx_t_8; __pyx_t_8 = 0; } __pyx_v_indices = __pyx_t_2; __pyx_t_2 = 0;
+8691: return d[indices]
__Pyx_TraceLine(8691,0,__PYX_ERR(0, 8691, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_v_d, __pyx_v_indices); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8691, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
8692: else:
+8693: d_array = np.array(d) if not hasattr(d, '__array__') else d
__Pyx_TraceLine(8693,0,__PYX_ERR(0, 8693, __pyx_L1_error)) /*else*/ { __pyx_t_1 = __Pyx_HasAttr(__pyx_v_d, __pyx_n_u_array_2); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 8693, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_1); if (__pyx_t_4) { __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_d}; __pyx_t_8 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8693, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_2 = __pyx_t_8; __pyx_t_8 = 0; } else { __Pyx_INCREF(__pyx_v_d); __pyx_t_2 = __pyx_v_d; } __pyx_v_d_array = __pyx_t_2; __pyx_t_2 = 0;
+8694: indices = np.random.choice(len(d_array), n_samples, replace=replace
__Pyx_TraceLine(8694,0,__PYX_ERR(0, 8694, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_random); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_choice); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = PyObject_Length(__pyx_v_d_array); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8694, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 8694, __pyx_L1_error); __Pyx_INCREF(__pyx_v_n_samples); __Pyx_GIVEREF(__pyx_v_n_samples); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_n_samples)) __PYX_ERR(0, 8694, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_replace, __pyx_v_replace) < 0) __PYX_ERR(0, 8694, __pyx_L1_error) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8694, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_2 = __pyx_t_6; __pyx_t_6 = 0; } else {
+8695: ) if shuffle else np.arange(n_samples)
__Pyx_TraceLine(8695,0,__PYX_ERR(0, 8695, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_shuffle); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 8695, __pyx_L1_error) if (__pyx_t_4) { /* … */ __Pyx_TraceLine(8695,0,__PYX_ERR(0, 8695, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_arange); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_n_samples}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8695, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_2 = __pyx_t_6; __pyx_t_6 = 0; } __pyx_v_indices = __pyx_t_2; __pyx_t_2 = 0;
+8696: return d_array[indices] if d_array.ndim == 1 else d_array[indices, :]
__Pyx_TraceLine(8696,0,__PYX_ERR(0, 8696, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_d_array, __pyx_n_s_ndim); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = (__Pyx_PyInt_BoolEqObjC(__pyx_t_6, __pyx_int_1, 1, 0)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 8696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_4) { __pyx_t_6 = __Pyx_PyObject_GetItem(__pyx_v_d_array, __pyx_v_indices); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __pyx_t_6; __pyx_t_6 = 0; } else { __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 8696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_indices); __Pyx_GIVEREF(__pyx_v_indices); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_indices)) __PYX_ERR(0, 8696, __pyx_L1_error); __Pyx_INCREF(__pyx_slice__130); __Pyx_GIVEREF(__pyx_slice__130); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_slice__130)) __PYX_ERR(0, 8696, __pyx_L1_error); __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_d_array, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = __pyx_t_5; __pyx_t_5 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; }
8697:
8698:
+8699: def get_valid_key(input_key, default_key, substitute_key_dict=None,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_284get_valid_key(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_283get_valid_key, "\n Validates an input key and substitutes it with a valid key if necessary,\n based on a mapping of valid keys to their possible substitutes. If the input\n key is not provided or is invalid, a default key is used.\n\n Parameters\n ----------\n input_key : str\n The key to validate and possibly substitute.\n default_key : str\n The default key to use if input_key is None, empty, or not found in \n the substitute mapping.\n substitute_key_dict : dict, optional\n A mapping of valid keys to lists of their possible substitutes. This\n allows for flexible key substitution and validation.\n regex_pattern: str, default = '[#&*@!,;\\s-]\\s*'\n The base pattern to split the text into a columns\n deep_search: bool, default=False \n If deep-search, the key finder is no sensistive to lower/upper case \n or whether a numeric data is included. \n Returns\n -------\n str\n A valid key, which is either the original input_key if valid, a substituted\n key if the original was found in the substitute mappings, or the default_key.\n\n Notes\n -----\n This function also leverages an external validation through `key_checker` for\n a deep search validation, ensuring the returned key is within the set of valid keys.\n \n Example\n -------\n >>> from gofast.tools.coreutils import get_valid_key\n >>> substitute_key_dict = {'valid_key1': ['vk1', 'key1'], 'valid_key2': ['vk2', 'key2']}\n >>> get_valid_key('vk1', 'default_key', substitute_key_dict)\n 'valid_key1'\n >>> get_valid_key('unknown_key', 'default_key', substitute_key_dict)\n 'KeyError...'\n \n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_284get_valid_key = {"get_valid_key", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_284get_valid_key, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_283get_valid_key}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_284get_valid_key(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_input_key = 0; PyObject *__pyx_v_default_key = 0; PyObject *__pyx_v_substitute_key_dict = 0; PyObject *__pyx_v_regex_pattern = 0; PyObject *__pyx_v_deep_search = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_valid_key (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input_key,&__pyx_n_s_default_key,&__pyx_n_s_substitute_key_dict,&__pyx_n_s_regex_pattern,&__pyx_n_s_deep_search,0}; PyObject* values[5] = {0,0,0,0,0}; values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_kp_u_s_s_3))); /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_283get_valid_key(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_input_key, PyObject *__pyx_v_default_key, PyObject *__pyx_v_substitute_key_dict, PyObject *__pyx_v_regex_pattern, PyObject *__pyx_v_deep_search) { PyObject *__pyx_v_valid_key = NULL; PyObject *__pyx_v_substitutes = NULL; PyObject *__pyx_v_normalized_substitutes = NULL; PyObject *__pyx_v_regex = NULL; PyObject *__pyx_v_valid_keys = NULL; PyObject *__pyx_9genexpr79__pyx_v_sub = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__325) __Pyx_TraceCall("get_valid_key", __pyx_f[0], 8699, 0, __PYX_ERR(0, 8699, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_input_key); __Pyx_INCREF(__pyx_v_substitute_key_dict); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils.get_valid_key", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_valid_key); __Pyx_XDECREF(__pyx_v_substitutes); __Pyx_XDECREF(__pyx_v_normalized_substitutes); __Pyx_XDECREF(__pyx_v_regex); __Pyx_XDECREF(__pyx_v_valid_keys); __Pyx_XDECREF(__pyx_9genexpr79__pyx_v_sub); __Pyx_XDECREF(__pyx_v_input_key); __Pyx_XDECREF(__pyx_v_substitute_key_dict); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__549 = PyTuple_Pack(11, __pyx_n_s_input_key, __pyx_n_s_default_key, __pyx_n_s_substitute_key_dict, __pyx_n_s_regex_pattern, __pyx_n_s_deep_search, __pyx_n_s_valid_key, __pyx_n_s_substitutes, __pyx_n_s_normalized_substitutes, __pyx_n_s_regex, __pyx_n_s_valid_keys, __pyx_n_s_sub); if (unlikely(!__pyx_tuple__549)) __PYX_ERR(0, 8699, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__549); __Pyx_GIVEREF(__pyx_tuple__549); __pyx_codeobj__325 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__549, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_valid_key, 8699, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__325)) __PYX_ERR(0, 8699, __pyx_L1_error) /* … */ __Pyx_TraceLine(8699,0,__PYX_ERR(0, 8699, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_284get_valid_key, 0, __pyx_n_s_get_valid_key, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__325)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8699, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__550); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_valid_key, __pyx_t_8) < 0) __PYX_ERR(0, 8699, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__550 = PyTuple_Pack(3, Py_None, ((PyObject*)__pyx_kp_u_s_s_3), ((PyObject *)Py_True)); if (unlikely(!__pyx_tuple__550)) __PYX_ERR(0, 8699, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__550); __Pyx_GIVEREF(__pyx_tuple__550);
+8700: regex_pattern = "[#&*@!,;\s]\s*", deep_search=True):
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_input_key)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8699, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_default_key)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8699, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("get_valid_key", 0, 2, 5, 1); __PYX_ERR(0, 8699, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_substitute_key_dict); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8699, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_regex_pattern); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8699, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_deep_search); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8699, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_valid_key") < 0)) __PYX_ERR(0, 8699, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_input_key = values[0]; __pyx_v_default_key = values[1]; __pyx_v_substitute_key_dict = values[2]; __pyx_v_regex_pattern = values[3]; __pyx_v_deep_search = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_valid_key", 0, 2, 5, __pyx_nargs); __PYX_ERR(0, 8699, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_valid_key", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_283get_valid_key(__pyx_self, __pyx_v_input_key, __pyx_v_default_key, __pyx_v_substitute_key_dict, __pyx_v_regex_pattern, __pyx_v_deep_search);
8701: """
8702: Validates an input key and substitutes it with a valid key if necessary,
8703: based on a mapping of valid keys to their possible substitutes. If the input
8704: key is not provided or is invalid, a default key is used.
8705:
8706: Parameters
8707: ----------
8708: input_key : str
8709: The key to validate and possibly substitute.
8710: default_key : str
8711: The default key to use if input_key is None, empty, or not found in
8712: the substitute mapping.
8713: substitute_key_dict : dict, optional
8714: A mapping of valid keys to lists of their possible substitutes. This
8715: allows for flexible key substitution and validation.
8716: regex_pattern: str, default = '[#&*@!,;\s-]\s*'
8717: The base pattern to split the text into a columns
8718: deep_search: bool, default=False
8719: If deep-search, the key finder is no sensistive to lower/upper case
8720: or whether a numeric data is included.
8721: Returns
8722: -------
8723: str
8724: A valid key, which is either the original input_key if valid, a substituted
8725: key if the original was found in the substitute mappings, or the default_key.
8726:
8727: Notes
8728: -----
8729: This function also leverages an external validation through `key_checker` for
8730: a deep search validation, ensuring the returned key is within the set of valid keys.
8731:
8732: Example
8733: -------
8734: >>> from gofast.tools.coreutils import get_valid_key
8735: >>> substitute_key_dict = {'valid_key1': ['vk1', 'key1'], 'valid_key2': ['vk2', 'key2']}
8736: >>> get_valid_key('vk1', 'default_key', substitute_key_dict)
8737: 'valid_key1'
8738: >>> get_valid_key('unknown_key', 'default_key', substitute_key_dict)
8739: 'KeyError...'
8740:
8741: """
8742: # Ensure substitute_mapping is a dictionary if not provided
+8743: substitute_key_dict = substitute_key_dict or {}
__Pyx_TraceLine(8743,0,__PYX_ERR(0, 8743, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_substitute_key_dict); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8743, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_substitute_key_dict); __pyx_t_1 = __pyx_v_substitute_key_dict; goto __pyx_L3_bool_binop_done; } __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8743, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_L3_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_substitute_key_dict, __pyx_t_1); __pyx_t_1 = 0;
8744:
8745: # Fallback to default_key if input_key is None or empty
+8746: input_key = input_key or default_key
__Pyx_TraceLine(8746,0,__PYX_ERR(0, 8746, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_input_key); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8746, __pyx_L1_error) if (!__pyx_t_2) { } else { __Pyx_INCREF(__pyx_v_input_key); __pyx_t_1 = __pyx_v_input_key; goto __pyx_L5_bool_binop_done; } __Pyx_INCREF(__pyx_v_default_key); __pyx_t_1 = __pyx_v_default_key; __pyx_L5_bool_binop_done:; __Pyx_DECREF_SET(__pyx_v_input_key, __pyx_t_1); __pyx_t_1 = 0;
8747:
8748: # Attempt to find a valid substitute for the input_key
+8749: for valid_key, substitutes in substitute_key_dict.items():
__Pyx_TraceLine(8749,0,__PYX_ERR(0, 8749, __pyx_L1_error)) __pyx_t_4 = 0; if (unlikely(__pyx_v_substitute_key_dict == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 8749, __pyx_L1_error) } __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_substitute_key_dict, 0, __pyx_n_s_items, (&__pyx_t_5), (&__pyx_t_6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; while (1) { __pyx_t_8 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_5, &__pyx_t_4, &__pyx_t_3, &__pyx_t_7, NULL, __pyx_t_6); if (unlikely(__pyx_t_8 == 0)) break; if (unlikely(__pyx_t_8 == -1)) __PYX_ERR(0, 8749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_7); __Pyx_XDECREF_SET(__pyx_v_valid_key, __pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_substitutes, __pyx_t_7); __pyx_t_7 = 0;
8750: # Case-insensitive comparison for substitutes
+8751: normalized_substitutes = [str(sub).lower() for sub in substitutes]
__Pyx_TraceLine(8751,0,__PYX_ERR(0, 8751, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_7); if (likely(PyList_CheckExact(__pyx_v_substitutes)) || PyTuple_CheckExact(__pyx_v_substitutes)) { __pyx_t_3 = __pyx_v_substitutes; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0; __pyx_t_10 = NULL; } else { __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_substitutes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8751, __pyx_L11_error) } for (;;) { if (likely(!__pyx_t_10)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8751, __pyx_L11_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 8751, __pyx_L11_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8751, __pyx_L11_error) #endif if (__pyx_t_9 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely((0 < 0))) __PYX_ERR(0, 8751, __pyx_L11_error) #else __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); #endif } } else { __pyx_t_11 = __pyx_t_10(__pyx_t_3); if (unlikely(!__pyx_t_11)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 8751, __pyx_L11_error) } break; } __Pyx_GOTREF(__pyx_t_11); } __Pyx_XDECREF_SET(__pyx_9genexpr79__pyx_v_sub, __pyx_t_11); __pyx_t_11 = 0; __pyx_t_12 = __Pyx_PyObject_Str(__pyx_9genexpr79__pyx_v_sub); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_lower); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_12 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_13))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_13, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL}; __pyx_t_11 = __Pyx_PyObject_FastCall(__pyx_t_13, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_7, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 8751, __pyx_L11_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_9genexpr79__pyx_v_sub); __pyx_9genexpr79__pyx_v_sub = 0; goto __pyx_L15_exit_scope; __pyx_L11_error:; __Pyx_XDECREF(__pyx_9genexpr79__pyx_v_sub); __pyx_9genexpr79__pyx_v_sub = 0; goto __pyx_L1_error; __pyx_L15_exit_scope:; } /* exit inner scope */ __Pyx_XDECREF_SET(__pyx_v_normalized_substitutes, ((PyObject*)__pyx_t_7)); __pyx_t_7 = 0;
8752:
+8753: if str(input_key).lower() in normalized_substitutes:
__Pyx_TraceLine(8753,0,__PYX_ERR(0, 8753, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Str(__pyx_v_input_key); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_lower); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_7 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8753, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_7, __pyx_v_normalized_substitutes, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8753, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_2) { /* … */ } } __pyx_L8_break:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+8754: input_key = valid_key
__Pyx_TraceLine(8754,0,__PYX_ERR(0, 8754, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_valid_key); __Pyx_DECREF_SET(__pyx_v_input_key, __pyx_v_valid_key);
+8755: break
__Pyx_TraceLine(8755,0,__PYX_ERR(0, 8755, __pyx_L1_error)) goto __pyx_L8_break;
8756:
+8757: regex = re.compile (fr'{regex_pattern}', flags=re.IGNORECASE)
__Pyx_TraceLine(8757,0,__PYX_ERR(0, 8757, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_re); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_compile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_v_regex_pattern, __pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GIVEREF(__pyx_t_1); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1)) __PYX_ERR(0, 8757, __pyx_L1_error); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_IGNORECASE); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_flags, __pyx_t_13) < 0) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8757, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_regex = __pyx_t_13; __pyx_t_13 = 0;
8758: # use valid keys only if substitute_key_dict not provided.
+8759: valid_keys = substitute_key_dict.keys() if substitute_key_dict else is_iterable(
__Pyx_TraceLine(8759,0,__PYX_ERR(0, 8759, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_substitute_key_dict); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8759, __pyx_L1_error) if (__pyx_t_2) { __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_substitute_key_dict, __pyx_n_s_keys); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_7 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_13 = __pyx_t_1; __pyx_t_1 = 0; } else { __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_is_iterable); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); /* … */ __Pyx_TraceLine(8760,0,__PYX_ERR(0, 8760, __pyx_L1_error)) __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(__pyx_v_default_key); __Pyx_GIVEREF(__pyx_v_default_key); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_default_key)) __PYX_ERR(0, 8759, __pyx_L1_error); /* … */ __Pyx_TraceLine(8759,0,__PYX_ERR(0, 8759, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8759, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_13 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_v_valid_keys = __pyx_t_13; __pyx_t_13 = 0;
+8760: default_key, exclude_string=True, transform=True)
__pyx_t_7 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8760, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_exclude_string, Py_True) < 0) __PYX_ERR(0, 8760, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_transform, Py_True) < 0) __PYX_ERR(0, 8760, __pyx_L1_error)
+8761: valid_keys = set (list(valid_keys) + [default_key])
__Pyx_TraceLine(8761,0,__PYX_ERR(0, 8761, __pyx_L1_error)) __pyx_t_13 = PySequence_List(__pyx_v_valid_keys); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_default_key); __Pyx_GIVEREF(__pyx_v_default_key); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_default_key)) __PYX_ERR(0, 8761, __pyx_L1_error); __pyx_t_7 = PyNumber_Add(__pyx_t_13, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PySet_New(__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8761, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF_SET(__pyx_v_valid_keys, __pyx_t_3); __pyx_t_3 = 0;
8762: # Further validate the (possibly substituted) input_key
+8763: input_key = key_checker(input_key, valid_keys=valid_keys,
__Pyx_TraceLine(8763,0,__PYX_ERR(0, 8763, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_key_checker); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 8763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_input_key); __Pyx_GIVEREF(__pyx_v_input_key); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_input_key)) __PYX_ERR(0, 8763, __pyx_L1_error); __pyx_t_13 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_valid_keys, __pyx_v_valid_keys) < 0) __PYX_ERR(0, 8763, __pyx_L1_error) /* … */ __Pyx_TraceLine(8763,0,__PYX_ERR(0, 8763, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_7, __pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF_SET(__pyx_v_input_key, __pyx_t_11); __pyx_t_11 = 0;
+8764: deep_search=deep_search,regex = regex )
__Pyx_TraceLine(8764,0,__PYX_ERR(0, 8764, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_deep_search, __pyx_v_deep_search) < 0) __PYX_ERR(0, 8763, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_regex, __pyx_v_regex) < 0) __PYX_ERR(0, 8763, __pyx_L1_error)
8765:
+8766: return input_key
__Pyx_TraceLine(8766,0,__PYX_ERR(0, 8766, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_input_key); __pyx_r = __pyx_v_input_key; goto __pyx_L0;
8767:
+8768: def process_and_extract_data(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_286process_and_extract_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_285process_and_extract_data, "\n Extracts and processes data from various input types, focusing on column \n extraction from pandas DataFrames and conversion of inputs to numpy \n arrays or pandas Series.\n\n Parameters\n ----------\n *args : ArrayLike\n A variable number of inputs, each can be a list, numpy array, pandas \n Series,dictionary, or pandas DataFrame.\n columns : List[Union[str, int]], optional\n Specific columns to extract from pandas DataFrames. If not provided, \n the function behaves differently based on `allow_split`.\n enforce_extraction : bool, default=True\n Forces the function to try extracting `columns` from DataFrames. \n If False, DataFrames are returned without column extraction unless \n `allow_split` is True.\n Removing non-conforming elements if True.\n allow_split : bool, default=False\n If True and a DataFrame is provided without `columns`, splits the \n DataFrame into its constituent columns.\n search_multiple : bool, default=False\n Allows searching for `columns` across multiple DataFrame inputs. Once \n a column is found, it is not searched for in subsequent DataFrames.\n ensure_uniform_length : bool, default=False\n Checks that all extracted arrays have the same length. Raises an error\n if they don't.\n to_array : bool, default=False\n Converts all extracted pandas Series to numpy arrays.\n on_error : str, {'raise', 'ignore'}, default='raise'\n Determines how to handle errors during column extraction or when \n enforcing uniform length. 'raise' will raise an error, 'ignore' will \n skip the problematic input.\n\n Returns\n -------\n List[np.ndarray]\n A list of numpy arrays or pandas Series extracted based \n on the specified conditions.\n\n Examples\n --------\n >>> import numpy as np \n >>> import pandas as pd \n >>> from gofast.tools.coreutils import process""_and_extract_data\n >>> data = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})\n >>> process_and_extract_data(data, columns=['A'], to_array=True)\n [array([1, 2, 3])]\n\n Splitting DataFrame into individual arrays:\n\n >>> process_and_extract_data(data, allow_split=True, to_array=True)\n [array([1, 2, 3]), array([4, 5, 6])]\n\n Extracting columns from multiple DataFrames:\n\n >>> data2 = pd.DataFrame({'C': [7, 8, 9], 'D': [10, 11, 12]})\n >>> process_and_extract_data(data, data2, columns=['A', 'C'], \n search_multiple=True, to_array=True)\n [array([1, 2, 3]), array([7, 8, 9])]\n\n Handling mixed data types:\n\n >>> process_and_extract_data([1, 2, 3], {'E': [13, 14, 15]}, to_array=True)\n [array([1, 2, 3]), array([13, 14, 15])]\n \n Extracting columns from multiple DataFrames and enforcing uniform length:\n >>> data2 = pd.DataFrame({'C': [7, 8, 9, 10], 'D': [11, 12, 13, 14]})\n >>> result = process_and_extract_data(\n data, data2, columns=['A', 'C'],search_multiple=True,\n ensure_uniform_length=True, to_array=True)\n ValueError: Extracted data arrays do not have uniform length.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_286process_and_extract_data = {"process_and_extract_data", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_286process_and_extract_data, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_285process_and_extract_data}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_286process_and_extract_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_enforce_extraction = 0; PyObject *__pyx_v_allow_split = 0; PyObject *__pyx_v_search_multiple = 0; PyObject *__pyx_v_ensure_uniform_length = 0; PyObject *__pyx_v_to_array = 0; PyObject *__pyx_v_on_error = 0; PyObject *__pyx_v_args = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("process_and_extract_data (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_args = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_columns,&__pyx_n_s_enforce_extraction,&__pyx_n_s_allow_split,&__pyx_n_s_search_multiple,&__pyx_n_s_ensure_uniform_length,&__pyx_n_s_to_array,&__pyx_n_s_on_error,0}; PyObject* values[7] = {0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_args); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_285process_and_extract_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_columns, PyObject *__pyx_v_enforce_extraction, PyObject *__pyx_v_allow_split, PyObject *__pyx_v_search_multiple, PyObject *__pyx_v_ensure_uniform_length, PyObject *__pyx_v_to_array, PyObject *__pyx_v_on_error, PyObject *__pyx_v_args) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *__pyx_cur_scope; PyObject *__pyx_v__process_input = 0; PyObject *__pyx_v_arg = NULL; PyObject *__pyx_v_result = NULL; PyObject *__pyx_gb_6gofast_5tools_9coreutils_24process_and_extract_data_4generator13 = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__327) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 8768, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("process_and_extract_data", __pyx_f[0], 8768, 0, __PYX_ERR(0, 8768, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_enforce_extraction = __pyx_v_enforce_extraction; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_enforce_extraction); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_enforce_extraction); __pyx_cur_scope->__pyx_v_allow_split = __pyx_v_allow_split; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_allow_split); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_allow_split); __pyx_cur_scope->__pyx_v_search_multiple = __pyx_v_search_multiple; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_search_multiple); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_search_multiple); __pyx_cur_scope->__pyx_v_on_error = __pyx_v_on_error; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_on_error); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_on_error); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("gofast.tools.coreutils.process_and_extract_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__process_input); __Pyx_XDECREF(__pyx_v_arg); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_24process_and_extract_data_4generator13); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__551 = PyTuple_Pack(16, __pyx_n_s_columns, __pyx_n_s_enforce_extraction, __pyx_n_s_allow_split, __pyx_n_s_search_multiple, __pyx_n_s_ensure_uniform_length, __pyx_n_s_to_array, __pyx_n_s_on_error, __pyx_n_s_args, __pyx_n_s_extracted_data, __pyx_n_s_columns_found, __pyx_n_s_process_input, __pyx_n_s_process_input, __pyx_n_s_arg, __pyx_n_s_result, __pyx_n_s_genexpr, __pyx_n_s_genexpr); if (unlikely(!__pyx_tuple__551)) __PYX_ERR(0, 8768, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__551); __Pyx_GIVEREF(__pyx_tuple__551); /* … */ __Pyx_TraceLine(8768,0,__PYX_ERR(0, 8768, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); /* … */ __Pyx_TraceLine(8768,0,__PYX_ERR(0, 8768, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_columns, __pyx_kp_s_Optional_List_Union_str_int) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_enforce_extraction, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_allow_split, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_search_multiple, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_ensure_uniform_length, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_to_array, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_on_error, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_args, __pyx_n_s_ArrayLike) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_List_np_ndarray) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_286process_and_extract_data, 0, __pyx_n_s_process_and_extract_data, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__327)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8768, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_4, __pyx_t_8); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_5); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_process_and_extract_data, __pyx_t_4) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_codeobj__327 = (PyObject*)__Pyx_PyCode_New(0, 0, 7, 16, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__551, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_process_and_extract_data, 8768, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__327)) __PYX_ERR(0, 8768, __pyx_L1_error) /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data { PyObject_HEAD PyObject *__pyx_v_allow_split; PyObject *__pyx_v_columns_found; PyObject *__pyx_v_enforce_extraction; PyObject *__pyx_v_extracted_data; PyObject *__pyx_v_on_error; PyObject *__pyx_v_search_multiple; };
8769: *args: ArrayLike,
+8770: columns: Optional[List[Union[str, int]]] = None,
values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None)); /* … */ __Pyx_TraceLine(8770,0,__PYX_ERR(0, 8770, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_columns, Py_None) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_enforce_extraction, ((PyObject *)Py_True)) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_allow_split, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_search_multiple, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_ensure_uniform_length, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_to_array, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 8768, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_on_error, ((PyObject*)__pyx_n_u_raise)) < 0) __PYX_ERR(0, 8768, __pyx_L1_error)
+8771: enforce_extraction: bool = True,
values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_True)));
+8772: allow_split: bool = False,
values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False)));
+8773: search_multiple: bool = False,
values[3] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False)));
+8774: ensure_uniform_length: bool = False,
values[4] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False)));
+8775: to_array: bool = False,
values[5] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[6] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)((PyObject*)__pyx_n_u_raise))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args > 0 && likely(kw_args <= 7)) { Py_ssize_t index; for (index = 0; index < 7 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8768, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "process_and_extract_data") < 0)) __PYX_ERR(0, 8768, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_columns = values[0]; __pyx_v_enforce_extraction = values[1]; __pyx_v_allow_split = values[2]; __pyx_v_search_multiple = values[3]; __pyx_v_ensure_uniform_length = values[4]; __pyx_v_to_array = values[5]; __pyx_v_on_error = ((PyObject*)values[6]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("process_and_extract_data", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 8768, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0; __Pyx_AddTraceback("gofast.tools.coreutils.process_and_extract_data", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_on_error), (&PyUnicode_Type), 0, "on_error", 1))) __PYX_ERR(0, 8776, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_285process_and_extract_data(__pyx_self, __pyx_v_columns, __pyx_v_enforce_extraction, __pyx_v_allow_split, __pyx_v_search_multiple, __pyx_v_ensure_uniform_length, __pyx_v_to_array, __pyx_v_on_error, __pyx_v_args);
8776: on_error: str = 'raise',
8777: ) -> List[np.ndarray]:
8778: """
8779: Extracts and processes data from various input types, focusing on column
8780: extraction from pandas DataFrames and conversion of inputs to numpy
8781: arrays or pandas Series.
8782:
8783: Parameters
8784: ----------
8785: *args : ArrayLike
8786: A variable number of inputs, each can be a list, numpy array, pandas
8787: Series,dictionary, or pandas DataFrame.
8788: columns : List[Union[str, int]], optional
8789: Specific columns to extract from pandas DataFrames. If not provided,
8790: the function behaves differently based on `allow_split`.
8791: enforce_extraction : bool, default=True
8792: Forces the function to try extracting `columns` from DataFrames.
8793: If False, DataFrames are returned without column extraction unless
8794: `allow_split` is True.
8795: Removing non-conforming elements if True.
8796: allow_split : bool, default=False
8797: If True and a DataFrame is provided without `columns`, splits the
8798: DataFrame into its constituent columns.
8799: search_multiple : bool, default=False
8800: Allows searching for `columns` across multiple DataFrame inputs. Once
8801: a column is found, it is not searched for in subsequent DataFrames.
8802: ensure_uniform_length : bool, default=False
8803: Checks that all extracted arrays have the same length. Raises an error
8804: if they don't.
8805: to_array : bool, default=False
8806: Converts all extracted pandas Series to numpy arrays.
8807: on_error : str, {'raise', 'ignore'}, default='raise'
8808: Determines how to handle errors during column extraction or when
8809: enforcing uniform length. 'raise' will raise an error, 'ignore' will
8810: skip the problematic input.
8811:
8812: Returns
8813: -------
8814: List[np.ndarray]
8815: A list of numpy arrays or pandas Series extracted based
8816: on the specified conditions.
8817:
8818: Examples
8819: --------
8820: >>> import numpy as np
8821: >>> import pandas as pd
8822: >>> from gofast.tools.coreutils import process_and_extract_data
8823: >>> data = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
8824: >>> process_and_extract_data(data, columns=['A'], to_array=True)
8825: [array([1, 2, 3])]
8826:
8827: Splitting DataFrame into individual arrays:
8828:
8829: >>> process_and_extract_data(data, allow_split=True, to_array=True)
8830: [array([1, 2, 3]), array([4, 5, 6])]
8831:
8832: Extracting columns from multiple DataFrames:
8833:
8834: >>> data2 = pd.DataFrame({'C': [7, 8, 9], 'D': [10, 11, 12]})
8835: >>> process_and_extract_data(data, data2, columns=['A', 'C'],
8836: search_multiple=True, to_array=True)
8837: [array([1, 2, 3]), array([7, 8, 9])]
8838:
8839: Handling mixed data types:
8840:
8841: >>> process_and_extract_data([1, 2, 3], {'E': [13, 14, 15]}, to_array=True)
8842: [array([1, 2, 3]), array([13, 14, 15])]
8843:
8844: Extracting columns from multiple DataFrames and enforcing uniform length:
8845: >>> data2 = pd.DataFrame({'C': [7, 8, 9, 10], 'D': [11, 12, 13, 14]})
8846: >>> result = process_and_extract_data(
8847: data, data2, columns=['A', 'C'],search_multiple=True,
8848: ensure_uniform_length=True, to_array=True)
8849: ValueError: Extracted data arrays do not have uniform length.
8850: """
+8851: extracted_data = []
__Pyx_TraceLine(8851,0,__PYX_ERR(0, 8851, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8851, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_extracted_data = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+8852: columns_found: Set[Union[str, int]] = set()
__Pyx_TraceLine(8852,0,__PYX_ERR(0, 8852, __pyx_L1_error)) __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8852, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_columns_found = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
8853:
+8854: def _process_input(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_24process_and_extract_data_1_process_input(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_24process_and_extract_data__process_input, "\n Processes each input based on its type, extracting specified columns \n if necessary, and converting to numpy array if specified.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_24process_and_extract_data_1_process_input = {"_process_input", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_24process_and_extract_data_1_process_input, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_24process_and_extract_data__process_input}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_24process_and_extract_data_1_process_input(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_input_data = 0; PyObject *__pyx_v_target_columns = 0; PyObject *__pyx_v_to_array = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_process_input (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_input_data,&__pyx_n_s_target_columns,&__pyx_n_s_to_array,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_input_data)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8854, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_target_columns)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8854, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_process_input", 1, 3, 3, 1); __PYX_ERR(0, 8854, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_to_array)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8854, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("_process_input", 1, 3, 3, 2); __PYX_ERR(0, 8854, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "_process_input") < 0)) __PYX_ERR(0, 8854, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_input_data = values[0]; __pyx_v_target_columns = values[1]; __pyx_v_to_array = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("_process_input", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 8854, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.process_and_extract_data._process_input", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_24process_and_extract_data__process_input(__pyx_self, __pyx_v_input_data, __pyx_v_target_columns, __pyx_v_to_array); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_24process_and_extract_data__process_input(PyObject *__pyx_self, PyObject *__pyx_v_input_data, PyObject *__pyx_v_target_columns, PyObject *__pyx_v_to_array) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *__pyx_cur_scope; struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *__pyx_outer_scope; PyObject *__pyx_v_col = NULL; PyObject *__pyx_v_data_to_add = NULL; PyObject *__pyx_v_arr = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; __Pyx_TraceCall("_process_input", __pyx_f[0], 8854, 0, __PYX_ERR(0, 8854, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_input_data); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.process_and_extract_data._process_input", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_col); __Pyx_XDECREF(__pyx_v_data_to_add); __Pyx_XDECREF(__pyx_v_arr); __Pyx_XDECREF(__pyx_v_input_data); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_6gofast_5tools_9coreutils_24process_and_extract_data_4generator13(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_tuple__328 = PyTuple_Pack(6, __pyx_n_s_input_data, __pyx_n_s_target_columns, __pyx_n_s_to_array, __pyx_n_s_col, __pyx_n_s_data_to_add, __pyx_n_s_arr); if (unlikely(!__pyx_tuple__328)) __PYX_ERR(0, 8854, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__328); __Pyx_GIVEREF(__pyx_tuple__328); /* … */ __Pyx_TraceLine(8854,0,__PYX_ERR(0, 8854, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8854, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_input_data, __pyx_n_s_ArrayLike) < 0) __PYX_ERR(0, 8854, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_target_columns, __pyx_kp_s_Optional_List_Union_str_int) < 0) __PYX_ERR(0, 8854, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_to_array, __pyx_n_s_bool) < 0) __PYX_ERR(0, 8854, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_return, __pyx_kp_s_Optional_np_ndarray) < 0) __PYX_ERR(0, 8854, __pyx_L1_error) __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_24process_and_extract_data_1_process_input, 0, __pyx_n_s_process_and_extract_data_locals_2, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__329)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8854, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v__process_input = __pyx_t_2; __pyx_t_2 = 0; __pyx_codeobj__329 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__328, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_process_input, 8854, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__329)) __PYX_ERR(0, 8854, __pyx_L1_error)
8855: input_data: ArrayLike,
8856: target_columns: Optional[List[Union[str, int]]],
8857: to_array: bool) -> Optional[np.ndarray]:
8858: """
8859: Processes each input based on its type, extracting specified columns
8860: if necessary, and converting to numpy array if specified.
8861: """
+8862: if isinstance(input_data, (list, tuple)):
__Pyx_TraceLine(8862,0,__PYX_ERR(0, 8862, __pyx_L1_error)) __pyx_t_2 = PyList_Check(__pyx_v_input_data); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = PyTuple_Check(__pyx_v_input_data); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+8863: input_data = np.array(input_data)
__Pyx_TraceLine(8863,0,__PYX_ERR(0, 8863, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_input_data}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8863, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_input_data, __pyx_t_3); __pyx_t_3 = 0;
+8864: return input_data if len(input_data.shape
__Pyx_TraceLine(8864,0,__PYX_ERR(0, 8864, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); /* … */ __Pyx_TraceLine(8865,0,__PYX_ERR(0, 8865, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8864, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(8864,0,__PYX_ERR(0, 8864, __pyx_L1_error)) __pyx_t_7 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8864, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(8864,0,__PYX_ERR(0, 8864, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_input_data); __pyx_t_3 = __pyx_v_input_data; } else {
+8865: ) == 1 or not enforce_extraction else None
__Pyx_TraceLine(8865,0,__PYX_ERR(0, 8865, __pyx_L1_error)) __pyx_t_2 = (__pyx_t_7 == 1); if (!__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_enforce_extraction)) { __Pyx_RaiseClosureNameError("enforce_extraction"); __PYX_ERR(0, 8865, __pyx_L1_error) } __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_enforce_extraction); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8865, __pyx_L1_error) __pyx_t_8 = (!__pyx_t_2); __pyx_t_1 = __pyx_t_8; __pyx_L6_bool_binop_done:; if (__pyx_t_1) { /* … */ __Pyx_TraceLine(8865,0,__PYX_ERR(0, 8865, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_t_3 = Py_None; } __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
8866:
+8867: elif isinstance(input_data, dict):
__Pyx_TraceLine(8867,0,__PYX_ERR(0, 8867, __pyx_L1_error)) __pyx_t_1 = PyDict_Check(__pyx_v_input_data); if (__pyx_t_1) { /* … */ }
+8868: input_data = pd.DataFrame(input_data)
__Pyx_TraceLine(8868,0,__PYX_ERR(0, 8868, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8868, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8868, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_input_data}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8868, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF_SET(__pyx_v_input_data, __pyx_t_3); __pyx_t_3 = 0;
8869:
+8870: if isinstance(input_data, pd.DataFrame):
__Pyx_TraceLine(8870,0,__PYX_ERR(0, 8870, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_DataFrame); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8870, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = PyObject_IsInstance(__pyx_v_input_data, __pyx_t_4); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 8870, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* … */ }
+8871: if target_columns:
__Pyx_TraceLine(8871,0,__PYX_ERR(0, 8871, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_target_columns); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8871, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L9; }
+8872: for col in target_columns:
__Pyx_TraceLine(8872,0,__PYX_ERR(0, 8872, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_target_columns)) || PyTuple_CheckExact(__pyx_v_target_columns)) { __pyx_t_4 = __pyx_v_target_columns; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0; __pyx_t_9 = NULL; } else { __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_target_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8872, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_4))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8872, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 8872, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8872, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 8872, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8872, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 8872, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_v_col, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(8872,0,__PYX_ERR(0, 8872, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+8873: if col in input_data.columns and (
__Pyx_TraceLine(8873,0,__PYX_ERR(0, 8873, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_columns); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8873, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_v_col, __pyx_t_3, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8873, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_8) { } else { __pyx_t_1 = __pyx_t_8; goto __pyx_L13_bool_binop_done; } /* … */ __Pyx_TraceLine(8873,0,__PYX_ERR(0, 8873, __pyx_L1_error)) if (__pyx_t_1) { /* … */ goto __pyx_L12; }
+8874: search_multiple or col not in columns_found):
__Pyx_TraceLine(8874,0,__PYX_ERR(0, 8874, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_search_multiple)) { __Pyx_RaiseClosureNameError("search_multiple"); __PYX_ERR(0, 8874, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_search_multiple); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8874, __pyx_L1_error) if (!__pyx_t_8) { } else { __pyx_t_1 = __pyx_t_8; goto __pyx_L13_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_columns_found)) { __Pyx_RaiseClosureNameError("columns_found"); __PYX_ERR(0, 8874, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_columns_found == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); __PYX_ERR(0, 8874, __pyx_L1_error) } __pyx_t_8 = (__Pyx_PySet_ContainsTF(__pyx_v_col, __pyx_cur_scope->__pyx_v_columns_found, Py_NE)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8874, __pyx_L1_error) __pyx_t_1 = __pyx_t_8; __pyx_L13_bool_binop_done:;
+8875: data_to_add = input_data[col].to_numpy(
__Pyx_TraceLine(8875,0,__PYX_ERR(0, 8875, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyObject_GetItem(__pyx_v_input_data, __pyx_v_col); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_to_numpy); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8875, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __pyx_t_3 = __pyx_t_5; __pyx_t_5 = 0; } else {
+8876: ) if to_array else input_data[col]
__Pyx_TraceLine(8876,0,__PYX_ERR(0, 8876, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_to_array); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8876, __pyx_L1_error) if (__pyx_t_1) { /* … */ __Pyx_TraceLine(8876,0,__PYX_ERR(0, 8876, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_input_data, __pyx_v_col); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8876, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = __pyx_t_5; __pyx_t_5 = 0; } __Pyx_XDECREF_SET(__pyx_v_data_to_add, __pyx_t_3); __pyx_t_3 = 0;
+8877: extracted_data.append(data_to_add)
__Pyx_TraceLine(8877,0,__PYX_ERR(0, 8877, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_extracted_data)) { __Pyx_RaiseClosureNameError("extracted_data"); __PYX_ERR(0, 8877, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_extracted_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 8877, __pyx_L1_error) } __pyx_t_12 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_extracted_data, __pyx_v_data_to_add); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 8877, __pyx_L1_error)
+8878: columns_found.add(col)
__Pyx_TraceLine(8878,0,__PYX_ERR(0, 8878, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_columns_found)) { __Pyx_RaiseClosureNameError("columns_found"); __PYX_ERR(0, 8878, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_columns_found == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "add"); __PYX_ERR(0, 8878, __pyx_L1_error) } __pyx_t_12 = PySet_Add(__pyx_cur_scope->__pyx_v_columns_found, __pyx_v_col); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 8878, __pyx_L1_error)
+8879: elif on_error == 'raise':
__Pyx_TraceLine(8879,0,__PYX_ERR(0, 8879, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_on_error)) { __Pyx_RaiseClosureNameError("on_error"); __PYX_ERR(0, 8879, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_on_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8879, __pyx_L1_error) if (unlikely(__pyx_t_1)) { /* … */ } __pyx_L12:;
+8880: raise ValueError(f"Column {col} not found in DataFrame.")
__Pyx_TraceLine(8880,0,__PYX_ERR(0, 8880, __pyx_L1_error)) __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_13 = 0; __pyx_t_14 = 127; __Pyx_INCREF(__pyx_kp_u_Column_2); __pyx_t_13 += 7; __Pyx_GIVEREF(__pyx_kp_u_Column_2); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Column_2); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_v_col, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_14 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_14) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_14; __pyx_t_13 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u_not_found_in_DataFrame_2); __pyx_t_13 += 24; __Pyx_GIVEREF(__pyx_kp_u_not_found_in_DataFrame_2); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_not_found_in_DataFrame_2); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8880, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 8880, __pyx_L1_error)
+8881: elif allow_split:
__Pyx_TraceLine(8881,0,__PYX_ERR(0, 8881, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_allow_split)) { __Pyx_RaiseClosureNameError("allow_split"); __PYX_ERR(0, 8881, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_allow_split); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8881, __pyx_L1_error) if (__pyx_t_1) { /* … */ } __pyx_L9:;
+8882: for col in input_data.columns:
__Pyx_TraceLine(8882,0,__PYX_ERR(0, 8882, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_columns); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; __pyx_t_9 = NULL; } else { __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8882, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8882, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 8882, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8882, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 8882, __pyx_L1_error) #else __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8882, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); #endif } } else { __pyx_t_4 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_4)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 8882, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_4); } __Pyx_XDECREF_SET(__pyx_v_col, __pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(8882,0,__PYX_ERR(0, 8882, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+8883: data_to_add = input_data[col].to_numpy(
__Pyx_TraceLine(8883,0,__PYX_ERR(0, 8883, __pyx_L1_error)) __pyx_t_11 = __Pyx_PyObject_GetItem(__pyx_v_input_data, __pyx_v_col); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_to_numpy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8883, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } else {
+8884: ) if to_array else input_data[col]
__Pyx_TraceLine(8884,0,__PYX_ERR(0, 8884, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_to_array); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8884, __pyx_L1_error) if (__pyx_t_1) { /* … */ __Pyx_TraceLine(8884,0,__PYX_ERR(0, 8884, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_GetItem(__pyx_v_input_data, __pyx_v_col); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8884, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __pyx_t_5; __pyx_t_5 = 0; } __Pyx_XDECREF_SET(__pyx_v_data_to_add, __pyx_t_4); __pyx_t_4 = 0;
+8885: extracted_data.append(data_to_add)
__Pyx_TraceLine(8885,0,__PYX_ERR(0, 8885, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_extracted_data)) { __Pyx_RaiseClosureNameError("extracted_data"); __PYX_ERR(0, 8885, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_extracted_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 8885, __pyx_L1_error) } __pyx_t_12 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_extracted_data, __pyx_v_data_to_add); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 8885, __pyx_L1_error)
+8886: return None
__Pyx_TraceLine(8886,0,__PYX_ERR(0, 8886, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
8887:
+8888: if isinstance(input_data, np.ndarray):
__Pyx_TraceLine(8888,0,__PYX_ERR(0, 8888, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8888, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = PyObject_IsInstance(__pyx_v_input_data, __pyx_t_4); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 8888, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_1) { /* … */ }
+8889: if input_data.ndim > 1 and allow_split:
__Pyx_TraceLine(8889,0,__PYX_ERR(0, 8889, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_ndim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8889, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8889, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8889, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_8) { } else { __pyx_t_1 = __pyx_t_8; goto __pyx_L22_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_allow_split)) { __Pyx_RaiseClosureNameError("allow_split"); __PYX_ERR(0, 8889, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_allow_split); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8889, __pyx_L1_error) __pyx_t_1 = __pyx_t_8; __pyx_L22_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+8890: input_data = np.hsplit(input_data, input_data.shape[1])
__Pyx_TraceLine(8890,0,__PYX_ERR(0, 8890, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_hsplit); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_shape); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_4, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_input_data, __pyx_t_10}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8890, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF_SET(__pyx_v_input_data, __pyx_t_3); __pyx_t_3 = 0;
+8891: for arr in input_data:
__Pyx_TraceLine(8891,0,__PYX_ERR(0, 8891, __pyx_L1_error)) if (likely(PyList_CheckExact(__pyx_v_input_data)) || PyTuple_CheckExact(__pyx_v_input_data)) { __pyx_t_3 = __pyx_v_input_data; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; __pyx_t_9 = NULL; } else { __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_input_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8891, __pyx_L1_error) } for (;;) { if (likely(!__pyx_t_9)) { if (likely(PyList_CheckExact(__pyx_t_3))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8891, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 8891, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8891, __pyx_L1_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 8891, __pyx_L1_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8891, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_9(__pyx_t_3); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 8891, __pyx_L1_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_v_arr, __pyx_t_5); __pyx_t_5 = 0; /* … */ __Pyx_TraceLine(8891,0,__PYX_ERR(0, 8891, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+8892: extracted_data.append(arr.squeeze())
__Pyx_TraceLine(8892,0,__PYX_ERR(0, 8892, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_extracted_data)) { __Pyx_RaiseClosureNameError("extracted_data"); __PYX_ERR(0, 8892, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_v_extracted_data == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "append"); __PYX_ERR(0, 8892, __pyx_L1_error) } __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_arr, __pyx_n_s_squeeze); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_10))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_5 = __Pyx_PyObject_FastCall(__pyx_t_10, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8892, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __pyx_t_12 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_extracted_data, __pyx_t_5); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 8892, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+8893: return None
__Pyx_TraceLine(8893,0,__PYX_ERR(0, 8893, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
+8894: elif input_data.ndim > 1 and enforce_extraction and on_error == 'raise':
__Pyx_TraceLine(8894,0,__PYX_ERR(0, 8894, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_ndim); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8894, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8894, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8894, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_8) { } else { __pyx_t_1 = __pyx_t_8; goto __pyx_L27_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_enforce_extraction)) { __Pyx_RaiseClosureNameError("enforce_extraction"); __PYX_ERR(0, 8894, __pyx_L1_error) } __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_enforce_extraction); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8894, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_1 = __pyx_t_8; goto __pyx_L27_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_on_error)) { __Pyx_RaiseClosureNameError("on_error"); __PYX_ERR(0, 8894, __pyx_L1_error) } __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_on_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8894, __pyx_L1_error) __pyx_t_1 = __pyx_t_8; __pyx_L27_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+8895: raise ValueError("Multidimensional array found while "
__Pyx_TraceLine(8895,0,__PYX_ERR(0, 8895, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__326, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8895, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 8895, __pyx_L1_error) /* … */ __pyx_tuple__326 = PyTuple_Pack(1, __pyx_kp_u_Multidimensional_array_found_whi); if (unlikely(!__pyx_tuple__326)) __PYX_ERR(0, 8895, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__326); __Pyx_GIVEREF(__pyx_tuple__326);
8896: "`enforce_extraction` is True.")
+8897: return input_data if to_array else np.squeeze(input_data)
__Pyx_TraceLine(8897,0,__PYX_ERR(0, 8897, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_to_array); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8897, __pyx_L1_error) if (__pyx_t_1) { __Pyx_INCREF(__pyx_v_input_data); __pyx_t_5 = __pyx_v_input_data; } else { __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_squeeze); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_v_input_data}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8897, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_5 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
8898:
+8899: return input_data.to_numpy() if to_array and isinstance(
__Pyx_TraceLine(8899,0,__PYX_ERR(0, 8899, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_to_array); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 8899, __pyx_L1_error) if (__pyx_t_8) { } else { __pyx_t_1 = __pyx_t_8; goto __pyx_L30_bool_binop_done; } /* … */ __Pyx_TraceLine(8899,0,__PYX_ERR(0, 8899, __pyx_L1_error)) __pyx_t_8 = PyObject_IsInstance(__pyx_v_input_data, __pyx_t_4); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 8899, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __pyx_t_8; __pyx_L30_bool_binop_done:; if (__pyx_t_1) { __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_input_data, __pyx_n_s_to_numpy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_10 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL}; __pyx_t_4 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 0+__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8899, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_5 = __pyx_t_4; __pyx_t_4 = 0; } else {
+8900: input_data, pd.Series) else input_data
__Pyx_TraceLine(8900,0,__PYX_ERR(0, 8900, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_pd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_Series); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8900, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(8900,0,__PYX_ERR(0, 8900, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_input_data); __pyx_t_5 = __pyx_v_input_data; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
8901:
+8902: for arg in args:
__Pyx_TraceLine(8902,0,__PYX_ERR(0, 8902, __pyx_L1_error)) __pyx_t_2 = __pyx_v_args; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8902, __pyx_L1_error) #endif if (__pyx_t_3 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely((0 < 0))) __PYX_ERR(0, 8902, __pyx_L1_error) #else __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8902, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); #endif __Pyx_XDECREF_SET(__pyx_v_arg, __pyx_t_1); __pyx_t_1 = 0; /* … */ __Pyx_TraceLine(8902,0,__PYX_ERR(0, 8902, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+8903: result = _process_input(arg, columns, to_array)
__Pyx_TraceLine(8903,0,__PYX_ERR(0, 8903, __pyx_L1_error)) __pyx_t_1 = __pyx_pf_6gofast_5tools_9coreutils_24process_and_extract_data__process_input(__pyx_v__process_input, __pyx_v_arg, __pyx_v_columns, __pyx_v_to_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8903, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF_SET(__pyx_v_result, __pyx_t_1); __pyx_t_1 = 0;
+8904: if result is not None:
__Pyx_TraceLine(8904,0,__PYX_ERR(0, 8904, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_result != Py_None); if (__pyx_t_4) { /* … */ }
+8905: extracted_data.append(result)
__Pyx_TraceLine(8905,0,__PYX_ERR(0, 8905, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_extracted_data, __pyx_v_result); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 8905, __pyx_L1_error)
8906:
+8907: if ensure_uniform_length and not all(len(x) == len(
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_24process_and_extract_data_2genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_38_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_38_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_38_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_38_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_38_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 8907, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *) __pyx_self;
__Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_24process_and_extract_data_4generator13, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_process_and_extract_data_locals, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 8907, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.process_and_extract_data.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_24process_and_extract_data_4generator13(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 8907, __pyx_L1_error)
/* … */
__Pyx_TraceLine(8907,0,__PYX_ERR(0, 8907, __pyx_L1_error))
__pyx_t_4 = PyObject_Length(__pyx_cur_scope->__pyx_v_x); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8907, __pyx_L1_error)
/* … */
__Pyx_TraceLine(8907,0,__PYX_ERR(0, 8907, __pyx_L1_error))
__pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8907, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_6 = (!(__pyx_t_4 == __pyx_t_5));
if (__pyx_t_6) {
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_False);
__pyx_r = Py_False;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
goto __pyx_L0;
}
/* … */
__Pyx_TraceLine(8907,0,__PYX_ERR(0, 8907, __pyx_L1_error))
__Pyx_XDECREF(__pyx_r);
__Pyx_INCREF(Py_True);
__pyx_r = Py_True;
goto __pyx_L0;
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(8907,0,__PYX_ERR(0, 8907, __pyx_L1_error))
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_ensure_uniform_length); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 8907, __pyx_L1_error)
if (__pyx_t_6) {
} else {
__pyx_t_4 = __pyx_t_6;
goto __pyx_L8_bool_binop_done;
}
/* … */
__Pyx_TraceLine(8908,0,__PYX_ERR(0, 8908, __pyx_L1_error))
__pyx_t_2 = __pyx_pf_6gofast_5tools_9coreutils_24process_and_extract_data_2genexpr(((PyObject*)__pyx_cur_scope), __pyx_cur_scope->__pyx_v_extracted_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8907, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
/* … */
__Pyx_TraceLine(8907,0,__PYX_ERR(0, 8907, __pyx_L1_error))
__pyx_t_1 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8907, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 8907, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_7 = (!__pyx_t_6);
__pyx_t_4 = __pyx_t_7;
__pyx_L8_bool_binop_done:;
if (__pyx_t_4) {
/* … */
}
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_38_genexpr {
PyObject_HEAD
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_37_process_and_extract_data *__pyx_outer_scope;
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_x;
};
+8908: extracted_data[0]) for x in extracted_data):
__Pyx_TraceLine(8908,0,__PYX_ERR(0, 8908, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 8908, __pyx_L1_error) } __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8908, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 8908, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_x); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_x, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(8908,0,__PYX_ERR(0, 8908, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_extracted_data)) { __Pyx_RaiseClosureNameError("extracted_data"); __PYX_ERR(0, 8908, __pyx_L1_error) } if (unlikely(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_extracted_data == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 8908, __pyx_L1_error) } __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_extracted_data, 0, long, 1, __Pyx_PyInt_From_long, 1, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 8908, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); /* … */ __Pyx_TraceLine(8908,0,__PYX_ERR(0, 8908, __pyx_L1_error)) } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*else*/ {
+8909: if on_error == 'raise':
__Pyx_TraceLine(8909,0,__PYX_ERR(0, 8909, __pyx_L1_error)) __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_on_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 8909, __pyx_L1_error) if (unlikely(__pyx_t_4)) { /* … */ }
+8910: raise ValueError("Extracted data arrays do not have uniform length.")
__Pyx_TraceLine(8910,0,__PYX_ERR(0, 8910, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__330, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8910, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 8910, __pyx_L1_error) /* … */ __pyx_tuple__330 = PyTuple_Pack(1, __pyx_kp_u_Extracted_data_arrays_do_not_hav); if (unlikely(!__pyx_tuple__330)) __PYX_ERR(0, 8910, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__330); __Pyx_GIVEREF(__pyx_tuple__330);
8911: else:
+8912: return []
__Pyx_TraceLine(8912,0,__PYX_ERR(0, 8912, __pyx_L1_error)) /*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8912, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; }
8913:
+8914: return extracted_data
__Pyx_TraceLine(8914,0,__PYX_ERR(0, 8914, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_extracted_data); __pyx_r = __pyx_cur_scope->__pyx_v_extracted_data; goto __pyx_L0;
8915:
+8916: def to_series_if(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_288to_series_if(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_287to_series_if, "\n Constructs a pandas Series from given values, optionally naming the series\n and its index.\n\n Parameters\n ----------\n *values : Any\n A variable number of inputs, each can be a scalar, float, int, or array-like object.\n value_names : Optional[List[str]]\n Names to be used for the index of the series. If not provided or if its length\n doesn't match the number of values, default numeric index is used.\n name : Optional[str]\n Name of the series.\n error : str, default 'ignore'\n Error handling strategy ('ignore' or 'raise'). If 'raise', errors during series\n construction lead to an exception.\n **kws : dict\n Additional keyword arguments passed to `pd.Series` constructor.\n\n Returns\n -------\n pd.Series or original values\n A pandas Series constructed from the inputs if successful, otherwise, the original\n values if the series construction is not applicable.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import to_series_if\n >>> series = to_series_if(0.5, 8, np.array(\n [6.3]), [5], 2, value_names=['a', 'b', 'c', 'd', 'e'])\n >>> print(series)\n a 0.5\n b 8.0\n c 6.3\n d 5.0\n e 2.0\n dtype: float64\n >>> series = to_series_if(0.5, 8, np.array([6.3, 7]), [5], 2,\n value_names=['a', 'b', 'c', 'd', 'e'], error='raise')\n ValueError: Failed to construct series, input types vary.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_288to_series_if = {"to_series_if", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_288to_series_if, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_287to_series_if}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_288to_series_if(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_value_names = 0; PyObject *__pyx_v_name = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_values = 0; PyObject *__pyx_v_kws = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("to_series_if (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_v_kws = PyDict_New(); if (unlikely(!__pyx_v_kws)) return NULL; __Pyx_GOTREF(__pyx_v_kws); __Pyx_INCREF(__pyx_args); __pyx_v_values = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value_names,&__pyx_n_s_name_2,&__pyx_n_s_error,0}; PyObject* values[3] = {0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(__pyx_v_values); __Pyx_DECREF(__pyx_v_kws); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_287to_series_if(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value_names, PyObject *__pyx_v_name, PyObject *__pyx_v_error, PyObject *__pyx_v_values, PyObject *__pyx_v_kws) { PyObject *__pyx_v_flattened_values = NULL; PyObject *__pyx_v_series = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_9genexpr81__pyx_v_val = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__331) __Pyx_TraceCall("to_series_if", __pyx_f[0], 8916, 0, __PYX_ERR(0, 8916, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_value_names); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); __Pyx_AddTraceback("gofast.tools.coreutils.to_series_if", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_flattened_values); __Pyx_XDECREF(__pyx_v_series); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_9genexpr81__pyx_v_val); __Pyx_XDECREF(__pyx_v_value_names); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__552 = PyTuple_Pack(9, __pyx_n_s_value_names, __pyx_n_s_name_2, __pyx_n_s_error, __pyx_n_s_values, __pyx_n_s_kws_2, __pyx_n_s_flattened_values, __pyx_n_s_series, __pyx_n_s_e, __pyx_n_s_val); if (unlikely(!__pyx_tuple__552)) __PYX_ERR(0, 8916, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__552); __Pyx_GIVEREF(__pyx_tuple__552); /* … */ __Pyx_TraceLine(8916,0,__PYX_ERR(0, 8916, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); /* … */ __Pyx_TraceLine(8916,0,__PYX_ERR(0, 8916, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_value_names, __pyx_kp_s_Optional_List_str) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_name_2, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_error, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_values, __pyx_n_s_Any) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_n_s_Series) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_288to_series_if, 0, __pyx_n_s_to_series_if, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__331)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8916, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_8, __pyx_t_4); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_to_series_if, __pyx_t_8) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_codeobj__331 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__552, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_to_series_if, 8916, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__331)) __PYX_ERR(0, 8916, __pyx_L1_error)
8917: *values: Any,
+8918: value_names: Optional[List[str]] = None,
values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None)); /* … */ __Pyx_TraceLine(8918,0,__PYX_ERR(0, 8918, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_value_names, Py_None) < 0) __PYX_ERR(0, 8916, __pyx_L1_error)
+8919: name: Optional[str] = None,
values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)((PyObject*)__pyx_n_u_ignore))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args > 0 && (kw_args <= 3)) { Py_ssize_t index; for (index = 0; index < 3 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8916, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, __pyx_v_kws, values + 0, 0, "to_series_if") < 0)) __PYX_ERR(0, 8916, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_value_names = values[0]; __pyx_v_name = values[1]; __pyx_v_error = ((PyObject*)values[2]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("to_series_if", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 8916, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_values); __pyx_v_values = 0; __Pyx_DECREF(__pyx_v_kws); __pyx_v_kws = 0; __Pyx_AddTraceback("gofast.tools.coreutils.to_series_if", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_error), (&PyUnicode_Type), 0, "error", 1))) __PYX_ERR(0, 8920, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_287to_series_if(__pyx_self, __pyx_v_value_names, __pyx_v_name, __pyx_v_error, __pyx_v_values, __pyx_v_kws); /* … */ __Pyx_TraceLine(8919,0,__PYX_ERR(0, 8919, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_name_2, Py_None) < 0) __PYX_ERR(0, 8916, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_error, ((PyObject*)__pyx_n_u_ignore)) < 0) __PYX_ERR(0, 8916, __pyx_L1_error)
8920: error: str = 'ignore',
8921: **kws
8922: ) -> Series:
8923: """
8924: Constructs a pandas Series from given values, optionally naming the series
8925: and its index.
8926:
8927: Parameters
8928: ----------
8929: *values : Any
8930: A variable number of inputs, each can be a scalar, float, int, or array-like object.
8931: value_names : Optional[List[str]]
8932: Names to be used for the index of the series. If not provided or if its length
8933: doesn't match the number of values, default numeric index is used.
8934: name : Optional[str]
8935: Name of the series.
8936: error : str, default 'ignore'
8937: Error handling strategy ('ignore' or 'raise'). If 'raise', errors during series
8938: construction lead to an exception.
8939: **kws : dict
8940: Additional keyword arguments passed to `pd.Series` constructor.
8941:
8942: Returns
8943: -------
8944: pd.Series or original values
8945: A pandas Series constructed from the inputs if successful, otherwise, the original
8946: values if the series construction is not applicable.
8947:
8948: Examples
8949: --------
8950: >>> from gofast.tools.coreutils import to_series_if
8951: >>> series = to_series_if(0.5, 8, np.array(
8952: [6.3]), [5], 2, value_names=['a', 'b', 'c', 'd', 'e'])
8953: >>> print(series)
8954: a 0.5
8955: b 8.0
8956: c 6.3
8957: d 5.0
8958: e 2.0
8959: dtype: float64
8960: >>> series = to_series_if(0.5, 8, np.array([6.3, 7]), [5], 2,
8961: value_names=['a', 'b', 'c', 'd', 'e'], error='raise')
8962: ValueError: Failed to construct series, input types vary.
8963: """
8964: # Validate input lengths and types
+8965: if value_names and len(value_names) != len(values):
__Pyx_TraceLine(8965,0,__PYX_ERR(0, 8965, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_value_names); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 8965, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = PyObject_Length(__pyx_v_value_names); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8965, __pyx_L1_error) __pyx_t_4 = __Pyx_PyTuple_GET_SIZE(__pyx_v_values); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8965, __pyx_L1_error) __pyx_t_2 = (__pyx_t_3 != __pyx_t_4); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+8966: if error == 'raise':
__Pyx_TraceLine(8966,0,__PYX_ERR(0, 8966, __pyx_L1_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8966, __pyx_L1_error) if (unlikely(__pyx_t_1)) { /* … */ }
+8967: raise ValueError("Length of `value_names` does not match the number of values.")
__Pyx_TraceLine(8967,0,__PYX_ERR(0, 8967, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__332, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8967, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 8967, __pyx_L1_error) /* … */ __pyx_tuple__332 = PyTuple_Pack(1, __pyx_kp_u_Length_of_value_names_does_not_m); if (unlikely(!__pyx_tuple__332)) __PYX_ERR(0, 8967, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__332); __Pyx_GIVEREF(__pyx_tuple__332);
+8968: value_names = None # Reset to default indexing
__Pyx_TraceLine(8968,0,__PYX_ERR(0, 8968, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_value_names, Py_None);
8969: # Attempt to construct series
+8970: try:
__Pyx_TraceLine(8970,0,__PYX_ERR(0, 8970, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L12_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L10_except_return:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L0; __pyx_L12_try_end:; }
8971: # Flatten array-like inputs to avoid creating Series of lists/arrays
+8972: flattened_values = [val[0] if isinstance(
__Pyx_TraceLine(8972,0,__PYX_ERR(0, 8972, __pyx_L7_error)) { /* enter inner scope */ __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8972, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(8972,0,__PYX_ERR(0, 8972, __pyx_L15_error)) __pyx_t_12 = __Pyx_GetItemInt(__pyx_9genexpr81__pyx_v_val, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 8972, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __pyx_t_10 = __pyx_t_12; __pyx_t_12 = 0; } else {
+8973: val, (list,tuple, np.ndarray, pd.Series)) and len(val) == 1 else val for val in values]
__Pyx_TraceLine(8973,0,__PYX_ERR(0, 8973, __pyx_L15_error)) __pyx_t_9 = __pyx_v_values; __Pyx_INCREF(__pyx_t_9); __pyx_t_4 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 8973, __pyx_L15_error) #endif if (__pyx_t_4 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_4); __Pyx_INCREF(__pyx_t_10); __pyx_t_4++; if (unlikely((0 < 0))) __PYX_ERR(0, 8973, __pyx_L15_error) #else __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 8973, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_10); #endif __Pyx_XDECREF_SET(__pyx_9genexpr81__pyx_v_val, __pyx_t_10); __pyx_t_10 = 0; /* … */ __Pyx_TraceLine(8972,0,__PYX_ERR(0, 8972, __pyx_L15_error)) __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8973, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_11); /* … */ __Pyx_TraceLine(8973,0,__PYX_ERR(0, 8973, __pyx_L15_error)) __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_ndarray); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 8973, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_pd); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 8973, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_Series); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8973, __pyx_L15_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; /* … */ __Pyx_TraceLine(8972,0,__PYX_ERR(0, 8972, __pyx_L15_error)) __pyx_t_14 = PyList_Check(__pyx_9genexpr81__pyx_v_val); if (!__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L20_bool_binop_done; } /* … */ __Pyx_TraceLine(8973,0,__PYX_ERR(0, 8973, __pyx_L15_error)) __pyx_t_14 = PyTuple_Check(__pyx_9genexpr81__pyx_v_val); if (!__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L20_bool_binop_done; } __pyx_t_14 = PyObject_IsInstance(__pyx_9genexpr81__pyx_v_val, __pyx_t_12); if (!__pyx_t_14) { } else { __pyx_t_2 = __pyx_t_14; goto __pyx_L20_bool_binop_done; } __pyx_t_14 = PyObject_IsInstance(__pyx_9genexpr81__pyx_v_val, __pyx_t_13); __pyx_t_2 = __pyx_t_14; __pyx_L20_bool_binop_done:; __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L18_bool_binop_done; } __pyx_t_3 = PyObject_Length(__pyx_9genexpr81__pyx_v_val); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 8973, __pyx_L15_error) __pyx_t_2 = (__pyx_t_3 == 1); __pyx_t_1 = __pyx_t_2; __pyx_L18_bool_binop_done:; if (__pyx_t_1) { /* … */ __Pyx_TraceLine(8973,0,__PYX_ERR(0, 8973, __pyx_L15_error)) __Pyx_INCREF(__pyx_9genexpr81__pyx_v_val); __pyx_t_10 = __pyx_9genexpr81__pyx_v_val; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 8972, __pyx_L15_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_9genexpr81__pyx_v_val); __pyx_9genexpr81__pyx_v_val = 0; goto __pyx_L25_exit_scope; __pyx_L15_error:; __Pyx_XDECREF(__pyx_9genexpr81__pyx_v_val); __pyx_9genexpr81__pyx_v_val = 0; goto __pyx_L7_error; __pyx_L25_exit_scope:; } /* exit inner scope */ __pyx_v_flattened_values = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+8974: series = pd.Series(flattened_values, index=value_names, name=name, **kws)
__Pyx_TraceLine(8974,0,__PYX_ERR(0, 8974, __pyx_L7_error)) __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_pd); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8974, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_Series); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8974, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 8974, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_flattened_values); __Pyx_GIVEREF(__pyx_v_flattened_values); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_flattened_values)) __PYX_ERR(0, 8974, __pyx_L7_error); __pyx_t_12 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 8974, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_index, __pyx_v_value_names) < 0) __PYX_ERR(0, 8974, __pyx_L7_error) if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_name_2, __pyx_v_name) < 0) __PYX_ERR(0, 8974, __pyx_L7_error) __pyx_t_10 = __pyx_t_12; __pyx_t_12 = 0; if (__Pyx_MergeKeywords(__pyx_t_10, __pyx_v_kws) < 0) __PYX_ERR(0, 8974, __pyx_L7_error) __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 8974, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_v_series = __pyx_t_12; __pyx_t_12 = 0;
+8975: except Exception as e:
__Pyx_TraceLine(8975,0,__PYX_ERR(0, 8975, __pyx_L9_except_error)) __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_15) { __Pyx_AddTraceback("gofast.tools.coreutils.to_series_if", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_10, &__pyx_t_5) < 0) __PYX_ERR(0, 8975, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_10); __pyx_v_e = __pyx_t_10; /*try:*/ { /* … */ __Pyx_TraceLine(8975,0,__PYX_ERR(0, 8975, __pyx_L31_error)) /*finally:*/ { __pyx_L31_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __Pyx_XGOTREF(__pyx_t_22); __Pyx_XGOTREF(__pyx_t_23); __pyx_t_15 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_21); __Pyx_XGIVEREF(__pyx_t_22); __Pyx_XGIVEREF(__pyx_t_23); __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23); } __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20); __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17; goto __pyx_L9_except_error; } __pyx_L30_return: { __pyx_t_23 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; __pyx_r = __pyx_t_23; __pyx_t_23 = 0; goto __pyx_L10_except_return; } } } goto __pyx_L9_except_error;
+8976: if error == 'raise':
__Pyx_TraceLine(8976,0,__PYX_ERR(0, 8976, __pyx_L31_error)) __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 8976, __pyx_L31_error) if (unlikely(__pyx_t_1)) { /* … */ }
+8977: raise ValueError(f"Failed to construct series due to: {e}")
__Pyx_TraceLine(8977,0,__PYX_ERR(0, 8977, __pyx_L31_error)) __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8977, __pyx_L31_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_13 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Failed_to_construct_series_due_t, __pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 8977, __pyx_L31_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_13); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 8977, __pyx_L31_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __PYX_ERR(0, 8977, __pyx_L31_error)
+8978: return values # Return the original values if series construction fails
__Pyx_TraceLine(8978,0,__PYX_ERR(0, 8978, __pyx_L31_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_values); __pyx_r = __pyx_v_values; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L30_return; }
8979:
+8980: return series
__Pyx_TraceLine(8980,0,__PYX_ERR(0, 8980, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_series); __pyx_r = __pyx_v_series; goto __pyx_L0;
8981:
+8982: def ensure_visualization_compatibility(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_290ensure_visualization_compatibility(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_289ensure_visualization_compatibility, "\n Evaluates and prepares the result for visualization, adjusting its format\n if necessary and determining whether visualization is feasible based on\n given parameters. If the conditions for visualization are not met, \n especially for singleton values, it can modify the view flag accordingly.\n\n Parameters\n ----------\n result : iterable or any\n The result to be checked and potentially modified for visualization.\n as_frame : bool, optional\n If True, the result is intended for frame-based visualization, which \n may prevent conversion of singleton iterables to a float. Defaults to False.\n view : bool, optional\n Flag indicating whether visualization is intended. This function may \n modify it to False if visualization conditions aren't met. Defaults to False.\n func_name : callable or str, optional\n The name of the function or a callable from which the name can be derived, \n used in generating verbose messages. Defaults to None.\n verbose : int, optional\n Controls verbosity level. A value greater than 0 enables verbose messages. \n Defaults to 0.\n allow_singleton_view : bool, optional\n Allows visualization of singleton values if set to True. If False and a \n singleton value is encountered, `view` is set to False. Defaults to False.\n\n Returns\n -------\n tuple\n A tuple containing the potentially modified result and the updated view flag.\n The result is modified if it's a singleton iterable and conditions require it.\n The view flag is updated based on the allowability of visualization.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import ensure_visualization_compatibility\n >>> result = [100.0]\n >>> modified_result, can_view = ensure_visualization_compatibility(\n ... result, as_frame=False, view=True, verbose=1, allow_singleton_view=False)\n Visualization is not allowed ""for singleton value.\n >>> print(modified_result, can_view)\n 100.0 False\n\n >>> result = [[100.0]]\n >>> modified_result, can_view = ensure_visualization_compatibility(\n ... result, as_frame=True, verbose=1)\n >>> print(modified_result, can_view)\n [[100.0]] True\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_290ensure_visualization_compatibility = {"ensure_visualization_compatibility", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_290ensure_visualization_compatibility, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_289ensure_visualization_compatibility}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_290ensure_visualization_compatibility(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_result = 0; PyObject *__pyx_v_as_frame = 0; PyObject *__pyx_v_view = 0; PyObject *__pyx_v_func_name = 0; PyObject *__pyx_v_verbose = 0; PyObject *__pyx_v_allow_singleton_view = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("ensure_visualization_compatibility (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_result,&__pyx_n_s_as_frame,&__pyx_n_s_view,&__pyx_n_s_func_name,&__pyx_n_s_verbose,&__pyx_n_s_allow_singleton_view,0}; PyObject* values[6] = {0,0,0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_289ensure_visualization_compatibility(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_result, PyObject *__pyx_v_as_frame, PyObject *__pyx_v_view, PyObject *__pyx_v_func_name, PyObject *__pyx_v_verbose, PyObject *__pyx_v_allow_singleton_view) { PyObject *__pyx_v_func_name_str = NULL; PyObject *__pyx_v_message_start = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__333) __Pyx_TraceCall("ensure_visualization_compatibility", __pyx_f[0], 8982, 0, __PYX_ERR(0, 8982, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_result); __Pyx_INCREF(__pyx_v_view); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.ensure_visualization_compatibility", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_func_name_str); __Pyx_XDECREF(__pyx_v_message_start); __Pyx_XDECREF(__pyx_v_result); __Pyx_XDECREF(__pyx_v_view); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__553 = PyTuple_Pack(8, __pyx_n_s_result, __pyx_n_s_as_frame, __pyx_n_s_view, __pyx_n_s_func_name, __pyx_n_s_verbose, __pyx_n_s_allow_singleton_view, __pyx_n_s_func_name_str, __pyx_n_s_message_start); if (unlikely(!__pyx_tuple__553)) __PYX_ERR(0, 8982, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__553); __Pyx_GIVEREF(__pyx_tuple__553); __pyx_codeobj__333 = (PyObject*)__Pyx_PyCode_New(6, 0, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__553, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_ensure_visualization_compatibili, 8982, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__333)) __PYX_ERR(0, 8982, __pyx_L1_error) /* … */ __Pyx_TraceLine(8982,0,__PYX_ERR(0, 8982, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_290ensure_visualization_compatibility, 0, __pyx_n_s_ensure_visualization_compatibili, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__333)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 8982, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__554); if (PyDict_SetItem(__pyx_d, __pyx_n_s_ensure_visualization_compatibili, __pyx_t_8) < 0) __PYX_ERR(0, 8982, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__554 = PyTuple_Pack(5, ((PyObject *)Py_False), ((PyObject *)Py_False), Py_None, ((PyObject *)__pyx_int_0), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__554)) __PYX_ERR(0, 8982, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__554); __Pyx_GIVEREF(__pyx_tuple__554);
+8983: result, as_frame=False, view=False, func_name=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_0)));
+8984: verbose=0, allow_singleton_view=False
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_result)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8982, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_as_frame); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8982, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_view); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8982, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_func_name); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8982, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_verbose); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8982, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_allow_singleton_view); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 8982, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "ensure_visualization_compatibility") < 0)) __PYX_ERR(0, 8982, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_result = values[0]; __pyx_v_as_frame = values[1]; __pyx_v_view = values[2]; __pyx_v_func_name = values[3]; __pyx_v_verbose = values[4]; __pyx_v_allow_singleton_view = values[5]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("ensure_visualization_compatibility", 0, 1, 6, __pyx_nargs); __PYX_ERR(0, 8982, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.ensure_visualization_compatibility", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_289ensure_visualization_compatibility(__pyx_self, __pyx_v_result, __pyx_v_as_frame, __pyx_v_view, __pyx_v_func_name, __pyx_v_verbose, __pyx_v_allow_singleton_view);
8985: ):
8986: """
8987: Evaluates and prepares the result for visualization, adjusting its format
8988: if necessary and determining whether visualization is feasible based on
8989: given parameters. If the conditions for visualization are not met,
8990: especially for singleton values, it can modify the view flag accordingly.
8991:
8992: Parameters
8993: ----------
8994: result : iterable or any
8995: The result to be checked and potentially modified for visualization.
8996: as_frame : bool, optional
8997: If True, the result is intended for frame-based visualization, which
8998: may prevent conversion of singleton iterables to a float. Defaults to False.
8999: view : bool, optional
9000: Flag indicating whether visualization is intended. This function may
9001: modify it to False if visualization conditions aren't met. Defaults to False.
9002: func_name : callable or str, optional
9003: The name of the function or a callable from which the name can be derived,
9004: used in generating verbose messages. Defaults to None.
9005: verbose : int, optional
9006: Controls verbosity level. A value greater than 0 enables verbose messages.
9007: Defaults to 0.
9008: allow_singleton_view : bool, optional
9009: Allows visualization of singleton values if set to True. If False and a
9010: singleton value is encountered, `view` is set to False. Defaults to False.
9011:
9012: Returns
9013: -------
9014: tuple
9015: A tuple containing the potentially modified result and the updated view flag.
9016: The result is modified if it's a singleton iterable and conditions require it.
9017: The view flag is updated based on the allowability of visualization.
9018:
9019: Examples
9020: --------
9021: >>> from gofast.tools.coreutils import ensure_visualization_compatibility
9022: >>> result = [100.0]
9023: >>> modified_result, can_view = ensure_visualization_compatibility(
9024: ... result, as_frame=False, view=True, verbose=1, allow_singleton_view=False)
9025: Visualization is not allowed for singleton value.
9026: >>> print(modified_result, can_view)
9027: 100.0 False
9028:
9029: >>> result = [[100.0]]
9030: >>> modified_result, can_view = ensure_visualization_compatibility(
9031: ... result, as_frame=True, verbose=1)
9032: >>> print(modified_result, can_view)
9033: [[100.0]] True
9034: """
+9035: if hasattr(result, '__iter__') and len(
__Pyx_TraceLine(9035,0,__PYX_ERR(0, 9035, __pyx_L1_error)) __pyx_t_2 = __Pyx_HasAttr(__pyx_v_result, __pyx_n_u_iter); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 9035, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } /* … */ __Pyx_TraceLine(9036,0,__PYX_ERR(0, 9036, __pyx_L1_error)) __pyx_t_3 = PyObject_Length(__pyx_v_result); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9035, __pyx_L1_error) /* … */ __Pyx_TraceLine(9035,0,__PYX_ERR(0, 9035, __pyx_L1_error)) if (__pyx_t_1) { /* … */ }
+9036: result) == 1 and not allow_singleton_view:
__pyx_t_2 = (__pyx_t_3 == 1);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_singleton_view); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 9036, __pyx_L1_error)
__pyx_t_4 = (!__pyx_t_2);
__pyx_t_1 = __pyx_t_4;
__pyx_L4_bool_binop_done:;
+9037: if not as_frame:
__Pyx_TraceLine(9037,0,__PYX_ERR(0, 9037, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_as_frame); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9037, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_1); if (__pyx_t_4) { /* … */ }
9038: # Attempt to convert to float value
+9039: try:
__Pyx_TraceLine(9039,0,__PYX_ERR(0, 9039, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L13_try_end; __pyx_L8_error:; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L10_except_error:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); goto __pyx_L1_error; __pyx_L9_exception_handled:; __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7); __pyx_L13_try_end:; }
+9040: result = float(result[0])
__Pyx_TraceLine(9040,0,__PYX_ERR(0, 9040, __pyx_L8_error)) __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_result, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9040, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_9 = __Pyx_PyNumber_Float(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9040, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_9); __pyx_t_9 = 0;
+9041: except ValueError:
__Pyx_TraceLine(9041,0,__PYX_ERR(0, 9041, __pyx_L10_except_error)) __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ValueError); if (__pyx_t_10) { __Pyx_ErrRestore(0,0,0); goto __pyx_L9_exception_handled; } goto __pyx_L10_except_error;
9042: pass # Keep the result as is if conversion fails
9043:
+9044: if view:
__Pyx_TraceLine(9044,0,__PYX_ERR(0, 9044, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_view); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9044, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+9045: if verbose > 0:
__Pyx_TraceLine(9045,0,__PYX_ERR(0, 9045, __pyx_L1_error)) __pyx_t_9 = PyObject_RichCompare(__pyx_v_verbose, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9045, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9045, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_4) { /* … */ }
9046: # Construct a user-friendly verbose message
+9047: func_name_str = f"{func_name.__name__} visualization" if callable(
__Pyx_TraceLine(9047,0,__PYX_ERR(0, 9047, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyCallable_Check(__pyx_v_func_name); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 9047, __pyx_L1_error) if (__pyx_t_4) { __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_func_name, __pyx_n_s_name); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_8, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_11, __pyx_kp_u_visualization); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9047, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_9 = __pyx_t_8; __pyx_t_8 = 0; } else { __Pyx_INCREF(__pyx_n_u_Visualization); __pyx_t_9 = __pyx_n_u_Visualization; } __pyx_v_func_name_str = ((PyObject*)__pyx_t_9); __pyx_t_9 = 0;
9048: func_name) else "Visualization"
9049: # Ensure the first letter is capitalized
+9050: message_start = func_name_str[0].upper() + func_name_str[1:]
__Pyx_TraceLine(9050,0,__PYX_ERR(0, 9050, __pyx_L1_error)) __pyx_t_12 = __Pyx_GetItemInt_Unicode(__pyx_v_func_name_str, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_12 == (Py_UCS4)-1)) __PYX_ERR(0, 9050, __pyx_L1_error) __pyx_t_8 = __Pyx_PyUnicode_FromOrdinal(__pyx_t_12); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_upper); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_10 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_11))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_10 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL}; __pyx_t_9 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_10, 0+__pyx_t_10); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } if (unlikely(__pyx_v_func_name_str == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); __PYX_ERR(0, 9050, __pyx_L1_error) } __pyx_t_11 = __Pyx_PyUnicode_Substring(__pyx_v_func_name_str, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_8 = PyNumber_Add(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9050, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_v_message_start = __pyx_t_8; __pyx_t_8 = 0;
+9051: print(f"{message_start} is not allowed for singleton value.")
__Pyx_TraceLine(9051,0,__PYX_ERR(0, 9051, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_v_message_start, __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_11 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_8, __pyx_kp_u_is_not_allowed_for_singleton_va); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_builtin_print, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9051, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+9052: view =False
__Pyx_TraceLine(9052,0,__PYX_ERR(0, 9052, __pyx_L1_error)) __Pyx_INCREF(Py_False); __Pyx_DECREF_SET(__pyx_v_view, Py_False);
+9053: return result, view
__Pyx_TraceLine(9053,0,__PYX_ERR(0, 9053, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9053, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(__pyx_v_result); __Pyx_GIVEREF(__pyx_v_result); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_result)) __PYX_ERR(0, 9053, __pyx_L1_error); __Pyx_INCREF(__pyx_v_view); __Pyx_GIVEREF(__pyx_v_view); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_view)) __PYX_ERR(0, 9053, __pyx_L1_error); __pyx_r = __pyx_t_8; __pyx_t_8 = 0; goto __pyx_L0;
9054:
+9055: def generate_mpl_styles(n, prop='color'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_292generate_mpl_styles(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_291generate_mpl_styles, "\n Generates a list of matplotlib property items (colors, markers, or line styles)\n to accommodate a specified number of samples.\n\n Parameters\n ----------\n n : int\n Number of property items needed. It generates a list of property items.\n prop : str, optional\n Name of the property to retrieve. Accepts 'color', 'marker', or 'line'.\n Defaults to 'color'.\n\n Returns\n -------\n list\n A list of property items with size equal to `n`.\n\n Raises\n ------\n ValueError\n If the `prop` argument is not one of the accepted property names.\n\n Examples\n --------\n Generate 10 color properties:\n\n >>> from gofast.tools.coreutils import generate_mpl_styles\n >>> generate_mpl_styles(10, prop='color')\n ['g', 'gray', 'y', 'blue', 'orange', 'purple', 'lime', 'k', 'cyan', 'magenta']\n\n Generate 5 marker properties:\n\n >>> generate_mpl_styles(5, prop='marker')\n ['o', '^', 's', '*', '+']\n\n Generate 3 line style properties:\n\n >>> generate_mpl_styles(3, prop='line')\n ['-', '--', '-.']\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_292generate_mpl_styles = {"generate_mpl_styles", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_292generate_mpl_styles, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_291generate_mpl_styles}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_292generate_mpl_styles(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_n = 0; PyObject *__pyx_v_prop = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("generate_mpl_styles (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,&__pyx_n_s_prop,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_color))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9055, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_prop); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9055, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "generate_mpl_styles") < 0)) __PYX_ERR(0, 9055, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_n = values[0]; __pyx_v_prop = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("generate_mpl_styles", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 9055, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.generate_mpl_styles", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_291generate_mpl_styles(__pyx_self, __pyx_v_n, __pyx_v_prop); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_291generate_mpl_styles(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n, PyObject *__pyx_v_prop) { PyObject *__pyx_v_mpl = NULL; PyObject *__pyx_v_D_COLORS = NULL; PyObject *__pyx_v_D_MARKERS = NULL; PyObject *__pyx_v_D_STYLES = NULL; PyObject *__pyx_v_properties_map = NULL; PyObject *__pyx_v_properties_list = NULL; PyObject *__pyx_v_repeated_properties = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__334) __Pyx_TraceCall("generate_mpl_styles", __pyx_f[0], 9055, 0, __PYX_ERR(0, 9055, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_n); __Pyx_INCREF(__pyx_v_prop); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.generate_mpl_styles", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_mpl); __Pyx_XDECREF(__pyx_v_D_COLORS); __Pyx_XDECREF(__pyx_v_D_MARKERS); __Pyx_XDECREF(__pyx_v_D_STYLES); __Pyx_XDECREF(__pyx_v_properties_map); __Pyx_XDECREF(__pyx_v_properties_list); __Pyx_XDECREF(__pyx_v_repeated_properties); __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_v_prop); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__555 = PyTuple_Pack(9, __pyx_n_s_n, __pyx_n_s_prop, __pyx_n_s_mpl, __pyx_n_s_D_COLORS, __pyx_n_s_D_MARKERS, __pyx_n_s_D_STYLES, __pyx_n_s_properties_map, __pyx_n_s_properties_list, __pyx_n_s_repeated_properties); if (unlikely(!__pyx_tuple__555)) __PYX_ERR(0, 9055, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__555); __Pyx_GIVEREF(__pyx_tuple__555); __pyx_codeobj__334 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__555, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_generate_mpl_styles, 9055, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__334)) __PYX_ERR(0, 9055, __pyx_L1_error) /* … */ __Pyx_TraceLine(9055,0,__PYX_ERR(0, 9055, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_292generate_mpl_styles, 0, __pyx_n_s_generate_mpl_styles, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__334)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9055, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__556); if (PyDict_SetItem(__pyx_d, __pyx_n_s_generate_mpl_styles, __pyx_t_8) < 0) __PYX_ERR(0, 9055, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__556 = PyTuple_Pack(1, ((PyObject*)__pyx_n_u_color)); if (unlikely(!__pyx_tuple__556)) __PYX_ERR(0, 9055, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__556); __Pyx_GIVEREF(__pyx_tuple__556);
9056: """
9057: Generates a list of matplotlib property items (colors, markers, or line styles)
9058: to accommodate a specified number of samples.
9059:
9060: Parameters
9061: ----------
9062: n : int
9063: Number of property items needed. It generates a list of property items.
9064: prop : str, optional
9065: Name of the property to retrieve. Accepts 'color', 'marker', or 'line'.
9066: Defaults to 'color'.
9067:
9068: Returns
9069: -------
9070: list
9071: A list of property items with size equal to `n`.
9072:
9073: Raises
9074: ------
9075: ValueError
9076: If the `prop` argument is not one of the accepted property names.
9077:
9078: Examples
9079: --------
9080: Generate 10 color properties:
9081:
9082: >>> from gofast.tools.coreutils import generate_mpl_styles
9083: >>> generate_mpl_styles(10, prop='color')
9084: ['g', 'gray', 'y', 'blue', 'orange', 'purple', 'lime', 'k', 'cyan', 'magenta']
9085:
9086: Generate 5 marker properties:
9087:
9088: >>> generate_mpl_styles(5, prop='marker')
9089: ['o', '^', 's', '*', '+']
9090:
9091: Generate 3 line style properties:
9092:
9093: >>> generate_mpl_styles(3, prop='line')
9094: ['-', '--', '-.']
9095: """
+9096: import matplotlib as mpl
__Pyx_TraceLine(9096,0,__PYX_ERR(0, 9096, __pyx_L1_error)) __pyx_t_1 = __Pyx_ImportDottedModule(__pyx_n_s_matplotlib, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9096, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_mpl = __pyx_t_1; __pyx_t_1 = 0;
9097:
+9098: D_COLORS = ["g", "gray", "y", "blue", "orange", "purple", "lime",
__Pyx_TraceLine(9098,0,__PYX_ERR(0, 9098, __pyx_L1_error)) __pyx_t_1 = PyList_New(10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9098, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_u_g); __Pyx_GIVEREF(__pyx_n_u_g); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_g)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_gray); __Pyx_GIVEREF(__pyx_n_u_gray); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_u_gray)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_y_4); __Pyx_GIVEREF(__pyx_n_u_y_4); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_u_y_4)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_blue); __Pyx_GIVEREF(__pyx_n_u_blue); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_u_blue)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_orange); __Pyx_GIVEREF(__pyx_n_u_orange); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_u_orange)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_purple); __Pyx_GIVEREF(__pyx_n_u_purple); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_u_purple)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_lime); __Pyx_GIVEREF(__pyx_n_u_lime); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_u_lime)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_k); __Pyx_GIVEREF(__pyx_n_u_k); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_u_k)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_cyan); __Pyx_GIVEREF(__pyx_n_u_cyan); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 8, __pyx_n_u_cyan)) __PYX_ERR(0, 9098, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_magenta); __Pyx_GIVEREF(__pyx_n_u_magenta); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 9, __pyx_n_u_magenta)) __PYX_ERR(0, 9098, __pyx_L1_error); __pyx_v_D_COLORS = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
9099: "k", "cyan", "magenta"]
+9100: D_MARKERS = ["o", "^", "s", "*", "+", "x", "D", "H"]
__Pyx_TraceLine(9100,0,__PYX_ERR(0, 9100, __pyx_L1_error)) __pyx_t_1 = PyList_New(8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_u_o); __Pyx_GIVEREF(__pyx_n_u_o); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_u_o)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__335); __Pyx_GIVEREF(__pyx_kp_u__335); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__335)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_s_2); __Pyx_GIVEREF(__pyx_n_u_s_2); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_u_s_2)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__36); __Pyx_GIVEREF(__pyx_kp_u__36); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__36)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__336); __Pyx_GIVEREF(__pyx_kp_u__336); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 4, __pyx_kp_u__336)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_x); __Pyx_GIVEREF(__pyx_n_u_x); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_u_x)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_D); __Pyx_GIVEREF(__pyx_n_u_D); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_u_D)) __PYX_ERR(0, 9100, __pyx_L1_error); __Pyx_INCREF(__pyx_n_u_H); __Pyx_GIVEREF(__pyx_n_u_H); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 7, __pyx_n_u_H)) __PYX_ERR(0, 9100, __pyx_L1_error); __pyx_v_D_MARKERS = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+9101: D_STYLES = ["-", "--", "-.", ":"]
__Pyx_TraceLine(9101,0,__PYX_ERR(0, 9101, __pyx_L1_error)) __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9101, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_kp_u__29); __Pyx_GIVEREF(__pyx_kp_u__29); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u__29)) __PYX_ERR(0, 9101, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__78); __Pyx_GIVEREF(__pyx_kp_u__78); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__78)) __PYX_ERR(0, 9101, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__337); __Pyx_GIVEREF(__pyx_kp_u__337); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__337)) __PYX_ERR(0, 9101, __pyx_L1_error); __Pyx_INCREF(__pyx_kp_u__32); __Pyx_GIVEREF(__pyx_kp_u__32); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 3, __pyx_kp_u__32)) __PYX_ERR(0, 9101, __pyx_L1_error); __pyx_v_D_STYLES = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
9102:
+9103: n = int(n) # Ensure n is an integer
__Pyx_TraceLine(9103,0,__PYX_ERR(0, 9103, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_n); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9103, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_1); __pyx_t_1 = 0;
+9104: prop = prop.lower().strip().replace('s', '') # Normalize the prop string
__Pyx_TraceLine(9104,0,__PYX_ERR(0, 9104, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_prop, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_strip); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_replace); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__232, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_prop, __pyx_t_1); __pyx_t_1 = 0;
+9105: if prop not in ('color', 'marker', 'line'):
__Pyx_TraceLine(9105,0,__PYX_ERR(0, 9105, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_prop); __pyx_t_1 = __pyx_v_prop; __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_color, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 9105, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_marker, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 9105, __pyx_L1_error) if (__pyx_t_7) { } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_line, Py_NE)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 9105, __pyx_L1_error) __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_7 = __pyx_t_6; if (unlikely(__pyx_t_7)) { /* … */ }
+9106: raise ValueError(f"Property '{prop}' is not available."
__Pyx_TraceLine(9106,0,__PYX_ERR(0, 9106, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_8 = 0; __pyx_t_9 = 127; __Pyx_INCREF(__pyx_kp_u_Property); __pyx_t_8 += 10; __Pyx_GIVEREF(__pyx_kp_u_Property); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Property); __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_v_prop, __pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) > __pyx_t_9) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) : __pyx_t_9; __pyx_t_8 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_kp_u_is_not_available_Expect_color_m); __pyx_t_8 += 56; __Pyx_GIVEREF(__pyx_kp_u_is_not_available_Expect_color_m); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_is_not_available_Expect_color_m); __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9106, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 9106, __pyx_L1_error)
9107: " Expect 'color', 'marker', or 'line'.")
9108:
9109: # Mapping property types to their corresponding lists
9110: properties_map = {
+9111: 'color': D_COLORS,
__Pyx_TraceLine(9111,0,__PYX_ERR(0, 9111, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9111, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_color, __pyx_v_D_COLORS) < 0) __PYX_ERR(0, 9111, __pyx_L1_error)
+9112: 'marker': D_MARKERS + list(mpl.lines.Line2D.markers.keys()),
__Pyx_TraceLine(9112,0,__PYX_ERR(0, 9112, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_mpl, __pyx_n_s_lines); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_Line2D); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_markers); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_keys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_4))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_5, 0+__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_t_4 = __Pyx_PySequence_ListKeepNew(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyNumber_Add(__pyx_v_D_MARKERS, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_marker, __pyx_t_3) < 0) __PYX_ERR(0, 9111, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+9113: 'line': D_STYLES
__Pyx_TraceLine(9113,0,__PYX_ERR(0, 9113, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_1, __pyx_n_u_line, __pyx_v_D_STYLES) < 0) __PYX_ERR(0, 9111, __pyx_L1_error) __pyx_v_properties_map = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
9114: }
9115:
9116: # Retrieve the specific list of properties based on the prop parameter
+9117: properties_list = properties_map[prop]
__Pyx_TraceLine(9117,0,__PYX_ERR(0, 9117, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyDict_GetItem(__pyx_v_properties_map, __pyx_v_prop); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9117, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_properties_list = __pyx_t_1; __pyx_t_1 = 0;
9118:
9119: # Generate the required number of properties, repeating the list if necessary
+9120: repeated_properties = list(itertools.chain(*itertools.repeat(properties_list, (
__Pyx_TraceLine(9120,0,__PYX_ERR(0, 9120, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_itertools); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_chain); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_itertools); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_repeat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* … */ __Pyx_TraceLine(9120,0,__PYX_ERR(0, 9120, __pyx_L1_error)) __pyx_t_2 = __Pyx_PySequence_Tuple(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+9121: n + len(properties_list) - 1) // len(properties_list))))[:n]
__Pyx_TraceLine(9121,0,__PYX_ERR(0, 9121, __pyx_L1_error)) __pyx_t_8 = PyObject_Length(__pyx_v_properties_list); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9121, __pyx_L1_error) __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = PyNumber_Add(__pyx_v_n, __pyx_t_4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 9121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_SubtractObjC(__pyx_t_10, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_8 = PyObject_Length(__pyx_v_properties_list); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9121, __pyx_L1_error) __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 9121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = PyNumber_FloorDivide(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = NULL; __pyx_t_5 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_5 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_v_properties_list, __pyx_t_11}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_5, 2+__pyx_t_5); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } /* … */ __Pyx_TraceLine(9121,0,__PYX_ERR(0, 9121, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_n); __pyx_t_1 = __pyx_v_n; __pyx_t_7 = (__pyx_t_1 == Py_None); if (__pyx_t_7) { __pyx_t_8 = PY_SSIZE_T_MAX; } else { __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 9121, __pyx_L1_error) __pyx_t_8 = __pyx_t_12; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyList_GetSlice(__pyx_t_2, 0, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_repeated_properties = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
9122:
+9123: return repeated_properties
__Pyx_TraceLine(9123,0,__PYX_ERR(0, 9123, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_repeated_properties); __pyx_r = __pyx_v_repeated_properties; goto __pyx_L0;
9124:
+9125: def generate_alpha_values(n, increase=True, start=0.1, end=1.0, epsilon=1e-10):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_294generate_alpha_values(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_293generate_alpha_values, "\n Generates a list of alpha (transparency) values that either increase or \n decrease gradually to fit the number of property items.\n \n Incorporates an epsilon to safeguard against division by zero.\n \n Parameters\n ----------\n n : int\n The number of alpha values to generate.\n increase : bool, optional\n If True, the alpha values will increase; if False, they will decrease.\n Defaults to True.\n start : float, optional\n The starting alpha value. Defaults to 0.1.\n end : float, optional\n The ending alpha value. Defaults to 1.0.\n epsilon : float, optional\n Small value to avert division by zero. Defaults to 1e-10.\n \n Returns\n -------\n list\n A list of alpha values of length `n`.\n \n Examples\n --------\n >>> from gofast.tools.coreutils import generate_alpha_values\n >>> generate_alpha_values(5, increase=True)\n [0.1, 0.325, 0.55, 0.775, 1.0]\n \n >>> generate_alpha_values(5, increase=False)\n [1.0, 0.775, 0.55, 0.325, 0.1]\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_294generate_alpha_values = {"generate_alpha_values", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_294generate_alpha_values, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_293generate_alpha_values}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_294generate_alpha_values(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_n = 0; PyObject *__pyx_v_increase = 0; PyObject *__pyx_v_start = 0; PyObject *__pyx_v_end = 0; PyObject *__pyx_v_epsilon = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("generate_alpha_values (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n,&__pyx_n_s_increase,&__pyx_n_s_start,&__pyx_n_s_end,&__pyx_n_s_epsilon,0}; PyObject* values[5] = {0,0,0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_0_1))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_1_0))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_1eneg_10))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9125, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_increase); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9125, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_start); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9125, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_end); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9125, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_epsilon); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9125, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "generate_alpha_values") < 0)) __PYX_ERR(0, 9125, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_n = values[0]; __pyx_v_increase = values[1]; __pyx_v_start = values[2]; __pyx_v_end = values[3]; __pyx_v_epsilon = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("generate_alpha_values", 0, 1, 5, __pyx_nargs); __PYX_ERR(0, 9125, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.generate_alpha_values", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_293generate_alpha_values(__pyx_self, __pyx_v_n, __pyx_v_increase, __pyx_v_start, __pyx_v_end, __pyx_v_epsilon); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_293generate_alpha_values(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_n, PyObject *__pyx_v_increase, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_epsilon) { PyObject *__pyx_v_alphas = NULL; PyObject *__pyx_9genexpr82__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__338) __Pyx_TraceCall("generate_alpha_values", __pyx_f[0], 9125, 0, __PYX_ERR(0, 9125, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_AddTraceback("gofast.tools.coreutils.generate_alpha_values", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_alphas); __Pyx_XDECREF(__pyx_9genexpr82__pyx_v_i); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__557 = PyTuple_Pack(7, __pyx_n_s_n, __pyx_n_s_increase, __pyx_n_s_start, __pyx_n_s_end, __pyx_n_s_epsilon, __pyx_n_s_alphas, __pyx_n_s_i); if (unlikely(!__pyx_tuple__557)) __PYX_ERR(0, 9125, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__557); __Pyx_GIVEREF(__pyx_tuple__557); __pyx_codeobj__338 = (PyObject*)__Pyx_PyCode_New(5, 0, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__557, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_generate_alpha_values, 9125, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__338)) __PYX_ERR(0, 9125, __pyx_L1_error) /* … */ __Pyx_TraceLine(9125,0,__PYX_ERR(0, 9125, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_294generate_alpha_values, 0, __pyx_n_s_generate_alpha_values, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__338)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__558); if (PyDict_SetItem(__pyx_d, __pyx_n_s_generate_alpha_values, __pyx_t_8) < 0) __PYX_ERR(0, 9125, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__558 = PyTuple_Pack(4, ((PyObject *)Py_True), ((PyObject*)__pyx_float_0_1), ((PyObject*)__pyx_float_1_0), ((PyObject*)__pyx_float_1eneg_10)); if (unlikely(!__pyx_tuple__558)) __PYX_ERR(0, 9125, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__558); __Pyx_GIVEREF(__pyx_tuple__558);
9126: """
9127: Generates a list of alpha (transparency) values that either increase or
9128: decrease gradually to fit the number of property items.
9129:
9130: Incorporates an epsilon to safeguard against division by zero.
9131:
9132: Parameters
9133: ----------
9134: n : int
9135: The number of alpha values to generate.
9136: increase : bool, optional
9137: If True, the alpha values will increase; if False, they will decrease.
9138: Defaults to True.
9139: start : float, optional
9140: The starting alpha value. Defaults to 0.1.
9141: end : float, optional
9142: The ending alpha value. Defaults to 1.0.
9143: epsilon : float, optional
9144: Small value to avert division by zero. Defaults to 1e-10.
9145:
9146: Returns
9147: -------
9148: list
9149: A list of alpha values of length `n`.
9150:
9151: Examples
9152: --------
9153: >>> from gofast.tools.coreutils import generate_alpha_values
9154: >>> generate_alpha_values(5, increase=True)
9155: [0.1, 0.325, 0.55, 0.775, 1.0]
9156:
9157: >>> generate_alpha_values(5, increase=False)
9158: [1.0, 0.775, 0.55, 0.325, 0.1]
9159: """
+9160: if not 0 <= start <= 1 or not 0 <= end <= 1:
__Pyx_TraceLine(9160,0,__PYX_ERR(0, 9160, __pyx_L1_error)) __pyx_t_2 = PyObject_RichCompare(__pyx_int_0, __pyx_v_start, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9160, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_2)) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_int_1, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9160, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 9160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = (!__pyx_t_3); if (!__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } __pyx_t_2 = PyObject_RichCompare(__pyx_int_0, __pyx_v_end, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9160, __pyx_L1_error) if (__Pyx_PyObject_IsTrue(__pyx_t_2)) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, __pyx_int_1, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9160, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_3 = (!__pyx_t_4); __pyx_t_1 = __pyx_t_3; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_1)) { /* … */ }
+9161: raise ValueError("Alpha values must be between 0 and 1.")
__Pyx_TraceLine(9161,0,__PYX_ERR(0, 9161, __pyx_L1_error)) __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__339, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 9161, __pyx_L1_error) /* … */ __pyx_tuple__339 = PyTuple_Pack(1, __pyx_kp_u_Alpha_values_must_be_between_0_a); if (unlikely(!__pyx_tuple__339)) __PYX_ERR(0, 9161, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__339); __Pyx_GIVEREF(__pyx_tuple__339);
9162:
9163: # Calculate the alpha values, utilizing epsilon in the denominator
9164: # to prevent division by zero
+9165: alphas = [start + (end - start) * i / max(n - 1, epsilon) for i in range(n)]
__Pyx_TraceLine(9165,0,__PYX_ERR(0, 9165, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_v_n); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) { __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9165, __pyx_L8_error) } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_6))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9165, __pyx_L8_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 9165, __pyx_L8_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9165, __pyx_L8_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 9165, __pyx_L8_error) #else __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); #endif } } else { __pyx_t_5 = __pyx_t_8(__pyx_t_6); if (unlikely(!__pyx_t_5)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 9165, __pyx_L8_error) } break; } __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF_SET(__pyx_9genexpr82__pyx_v_i, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyNumber_Subtract(__pyx_v_end, __pyx_v_start); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_9 = PyNumber_Multiply(__pyx_t_5, __pyx_9genexpr82__pyx_v_i); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_v_epsilon); __pyx_t_5 = __pyx_v_epsilon; __pyx_t_10 = __Pyx_PyInt_SubtractObjC(__pyx_v_n, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_12 = PyObject_RichCompare(__pyx_t_5, __pyx_t_10, Py_GT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 9165, __pyx_L8_error) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; if (__pyx_t_1) { __Pyx_INCREF(__pyx_t_5); __pyx_t_11 = __pyx_t_5; } else { __Pyx_INCREF(__pyx_t_10); __pyx_t_11 = __pyx_t_10; } __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = PyNumber_Add(__pyx_v_start, __pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 9165, __pyx_L8_error) __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_9genexpr82__pyx_v_i); __pyx_9genexpr82__pyx_v_i = 0; goto __pyx_L12_exit_scope; __pyx_L8_error:; __Pyx_XDECREF(__pyx_9genexpr82__pyx_v_i); __pyx_9genexpr82__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L12_exit_scope:; } /* exit inner scope */ __pyx_v_alphas = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
9166:
+9167: if not increase:
__Pyx_TraceLine(9167,0,__PYX_ERR(0, 9167, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_increase); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9167, __pyx_L1_error) __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { /* … */ }
+9168: alphas.reverse() # or alphas[::-1] creates new list
__Pyx_TraceLine(9168,0,__PYX_ERR(0, 9168, __pyx_L1_error)) __pyx_t_13 = PyList_Reverse(__pyx_v_alphas); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 9168, __pyx_L1_error)
9169:
+9170: return alphas
__Pyx_TraceLine(9170,0,__PYX_ERR(0, 9170, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_alphas); __pyx_r = __pyx_v_alphas; goto __pyx_L0;
9171:
+9172: def decompose_colormap(cmap_name, n_colors=5):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_296decompose_colormap(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_295decompose_colormap, "\n Decomposes a colormap into a list of individual colors.\n\n Parameters\n ----------\n cmap_name : str\n The name of the colormap to decompose.\n n_colors : int, default=5\n The number of colors to extract from the colormap.\n\n Returns\n -------\n list\n A list of RGBA color values from the colormap.\n\n Examples\n --------\n >>> colors = decompose_colormap('viridis', 5)\n >>> print(colors)\n [(0.267004, 0.004874, 0.329415, 1.0), ..., (0.993248, 0.906157, 0.143936, 1.0)]\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_296decompose_colormap = {"decompose_colormap", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_296decompose_colormap, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_295decompose_colormap}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_296decompose_colormap(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_cmap_name = 0; PyObject *__pyx_v_n_colors = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("decompose_colormap (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cmap_name,&__pyx_n_s_n_colors,0}; PyObject* values[2] = {0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)__pyx_int_5))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cmap_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9172, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_n_colors); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9172, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "decompose_colormap") < 0)) __PYX_ERR(0, 9172, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_cmap_name = values[0]; __pyx_v_n_colors = values[1]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("decompose_colormap", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 9172, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.decompose_colormap", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_295decompose_colormap(__pyx_self, __pyx_v_cmap_name, __pyx_v_n_colors); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_295decompose_colormap(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cmap_name, PyObject *__pyx_v_n_colors) { PyObject *__pyx_v_cmap = NULL; PyObject *__pyx_v_colors = NULL; PyObject *__pyx_9genexpr83__pyx_v_i = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__340) __Pyx_TraceCall("decompose_colormap", __pyx_f[0], 9172, 0, __PYX_ERR(0, 9172, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.decompose_colormap", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_cmap); __Pyx_XDECREF(__pyx_v_colors); __Pyx_XDECREF(__pyx_9genexpr83__pyx_v_i); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__559 = PyTuple_Pack(5, __pyx_n_s_cmap_name, __pyx_n_s_n_colors, __pyx_n_s_cmap, __pyx_n_s_colors, __pyx_n_s_i); if (unlikely(!__pyx_tuple__559)) __PYX_ERR(0, 9172, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__559); __Pyx_GIVEREF(__pyx_tuple__559); __pyx_codeobj__340 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__559, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_decompose_colormap, 9172, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__340)) __PYX_ERR(0, 9172, __pyx_L1_error) /* … */ __Pyx_TraceLine(9172,0,__PYX_ERR(0, 9172, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_296decompose_colormap, 0, __pyx_n_s_decompose_colormap, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__340)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__560); if (PyDict_SetItem(__pyx_d, __pyx_n_s_decompose_colormap, __pyx_t_8) < 0) __PYX_ERR(0, 9172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__560 = PyTuple_Pack(1, ((PyObject *)__pyx_int_5)); if (unlikely(!__pyx_tuple__560)) __PYX_ERR(0, 9172, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__560); __Pyx_GIVEREF(__pyx_tuple__560);
9173: """
9174: Decomposes a colormap into a list of individual colors.
9175:
9176: Parameters
9177: ----------
9178: cmap_name : str
9179: The name of the colormap to decompose.
9180: n_colors : int, default=5
9181: The number of colors to extract from the colormap.
9182:
9183: Returns
9184: -------
9185: list
9186: A list of RGBA color values from the colormap.
9187:
9188: Examples
9189: --------
9190: >>> colors = decompose_colormap('viridis', 5)
9191: >>> print(colors)
9192: [(0.267004, 0.004874, 0.329415, 1.0), ..., (0.993248, 0.906157, 0.143936, 1.0)]
9193: """
+9194: cmap = plt.cm.get_cmap(cmap_name, n_colors)
__Pyx_TraceLine(9194,0,__PYX_ERR(0, 9194, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_plt); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_cm); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_get_cmap); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_cmap_name, __pyx_v_n_colors}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 2+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9194, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_v_cmap = __pyx_t_1; __pyx_t_1 = 0;
+9195: colors = [cmap(i) for i in range(cmap.N)]
__Pyx_TraceLine(9195,0,__PYX_ERR(0, 9195, __pyx_L1_error)) { /* enter inner scope */ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_cmap, __pyx_n_s_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0; __pyx_t_6 = NULL; } else { __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9195, __pyx_L5_error) } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_2))) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9195, __pyx_L5_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 9195, __pyx_L5_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); #endif } else { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9195, __pyx_L5_error) #endif if (__pyx_t_5 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely((0 < 0))) __PYX_ERR(0, 9195, __pyx_L5_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); #endif } } else { __pyx_t_3 = __pyx_t_6(__pyx_t_2); if (unlikely(!__pyx_t_3)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 9195, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_3); } __Pyx_XDECREF_SET(__pyx_9genexpr83__pyx_v_i, __pyx_t_3); __pyx_t_3 = 0; __Pyx_INCREF(__pyx_v_cmap); __pyx_t_7 = __pyx_v_cmap; __pyx_t_8 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_9genexpr83__pyx_v_i}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 9195, __pyx_L5_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr83__pyx_v_i); __pyx_9genexpr83__pyx_v_i = 0; goto __pyx_L9_exit_scope; __pyx_L5_error:; __Pyx_XDECREF(__pyx_9genexpr83__pyx_v_i); __pyx_9genexpr83__pyx_v_i = 0; goto __pyx_L1_error; __pyx_L9_exit_scope:; } /* exit inner scope */ __pyx_v_colors = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+9196: return colors
__Pyx_TraceLine(9196,0,__PYX_ERR(0, 9196, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_colors); __pyx_r = __pyx_v_colors; goto __pyx_L0;
9197:
+9198: def get_colors_and_alphas(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_298get_colors_and_alphas(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_297get_colors_and_alphas, "\n Generates a sequence of color codes and alpha (transparency) values. \n \n Colors can be sourced from a specified Matplotlib colormap or generated \n using predefined styles. Alpha values can be arranged in ascending or \n descending order to create a gradient effect.\n\n The function also supports converting color tuples to named colors and \n allows for customizing the transparency gradient. Additionally, if only \n one color is generated, it can return that color directly as a string\n rather than wrapped in a list, for convenience in functions that expect a\n single color string.\n\n Parameters\n ----------\n count : int or iterable\n Specifies the number of colors and alpha values to generate. If an iterable \n is provided, its length determines the number of colors and alphas.\n cmap : str, optional\n The name of a Matplotlib colormap to generate colors. If None, colors are\n generated using predefined styles. Defaults to ``None``.\n alpha_direction : str, optional\n Direction to arrange alpha values for creating a gradient effect. ``increase``\n for ascending order, ``decrease`` for descending. Defaults to ``decrease``.\n start_alpha : float, optional\n The starting alpha value (transparency) in the gradient, between 0 (fully\n transparent) and 1 (fully opaque). Defaults to ``0.1``.\n end_alpha : float, optional\n The ending alpha value in the gradient, between 0 and 1. \n Defaults to ``1.0``.\n convert_to_named_color : bool, optional\n Converts color tuples to the nearest Matplotlib named color. This \n conversion applies when exactly one color is generated. \n Defaults to ``True``.\n single_color_as_string : bool, optional\n If True and only one color is generated, returns the color as a string \n instead of a list. Useful for functions expecting a single color string.\n Defaults to ``Fal""se``.\n consider_alpha : bool, optional\n Includes the alpha channel in the conversion process to named colors.\n Applicable only when `convert_to_named_color` is True. This is helpful\n when a human-readable color name is preferred over RGB values.\n Defaults to ``False``.\n ignore_color_names : bool, optional\n When True, any input color names (str) are ignored during conversion \n to named colors. Useful to exclude specific colors from conversion. \n Defaults to ``False``.\n color_space : str, optional\n The color space used for computing the closeness of colors. Can be \n ``rgb`` for RGB color space or ``lab`` for LAB color space, which is more \n perceptually uniform. Defaults to ``rgb``.\n error : str, optional\n Controls the error handling strategy when an invalid color is \n encountered during the conversion process. ``raise`` will throw an error,\n while ``ignore`` will proceed without error. Defaults to ``ignore``.\n\n Returns\n -------\n tuple\n A tuple containing either a list of color codes (RGBA or named color strings) \n and a corresponding list of alpha values, or a single color code and alpha \n value if `single_color_as_string` is True and only one color is generated.\n\n Examples\n --------\n Generate 3 random colors with decreasing alpha values:\n\n >>> get_colors_and_alphas(3)\n (['#1f77b4', '#ff7f0e', '#2ca02c'], [1.0, 0.55, 0.1])\n\n Generate 4 colors from the 'viridis' colormap with increasing alpha values:\n\n >>> get_colors_and_alphas(4, cmap='viridis', alpha_direction='increase')\n (['#440154', '#3b528b', '#21918c', '#5ec962'], [0.1, 0.4, 0.7, 1.0])\n\n Convert a single generated color to a named color:\n\n >>> get_colors_and_alphas(1, convert_to_named_color=True)\n ('rebeccapurple', [1.0])\n\n Get a single color as a string instead of a list:\n\n >>> get_colors_and_alph""as(1, single_color_as_string=True)\n ('#1f77b4', [1.0])\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_298get_colors_and_alphas = {"get_colors_and_alphas", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_298get_colors_and_alphas, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_297get_colors_and_alphas}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_298get_colors_and_alphas(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_count = 0; PyObject *__pyx_v_cmap = 0; PyObject *__pyx_v_alpha_direction = 0; PyObject *__pyx_v_start_alpha = 0; PyObject *__pyx_v_end_alpha = 0; PyObject *__pyx_v_convert_to_named_color = 0; PyObject *__pyx_v_single_color_as_string = 0; PyObject *__pyx_v_consider_alpha = 0; PyObject *__pyx_v_ignore_color_names = 0; PyObject *__pyx_v_color_space = 0; PyObject *__pyx_v_error = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("get_colors_and_alphas (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_count,&__pyx_n_s_cmap,&__pyx_n_s_alpha_direction,&__pyx_n_s_start_alpha,&__pyx_n_s_end_alpha,&__pyx_n_s_convert_to_named_color,&__pyx_n_s_single_color_as_string,&__pyx_n_s_consider_alpha,&__pyx_n_s_ignore_color_names,&__pyx_n_s_color_space,&__pyx_n_s_error,0}; PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_297get_colors_and_alphas(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_count, PyObject *__pyx_v_cmap, PyObject *__pyx_v_alpha_direction, PyObject *__pyx_v_start_alpha, PyObject *__pyx_v_end_alpha, PyObject *__pyx_v_convert_to_named_color, PyObject *__pyx_v_single_color_as_string, PyObject *__pyx_v_consider_alpha, PyObject *__pyx_v_ignore_color_names, PyObject *__pyx_v_color_space, PyObject *__pyx_v_error) { PyObject *__pyx_v_colors = NULL; PyObject *__pyx_v_increase = NULL; PyObject *__pyx_v_alphas = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__341) __Pyx_TraceCall("get_colors_and_alphas", __pyx_f[0], 9198, 0, __PYX_ERR(0, 9198, __pyx_L1_error)); __Pyx_INCREF(__pyx_v_count); __Pyx_INCREF(__pyx_v_cmap); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("gofast.tools.coreutils.get_colors_and_alphas", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_colors); __Pyx_XDECREF(__pyx_v_increase); __Pyx_XDECREF(__pyx_v_alphas); __Pyx_XDECREF(__pyx_v_count); __Pyx_XDECREF(__pyx_v_cmap); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__561 = PyTuple_Pack(14, __pyx_n_s_count, __pyx_n_s_cmap, __pyx_n_s_alpha_direction, __pyx_n_s_start_alpha, __pyx_n_s_end_alpha, __pyx_n_s_convert_to_named_color, __pyx_n_s_single_color_as_string, __pyx_n_s_consider_alpha, __pyx_n_s_ignore_color_names, __pyx_n_s_color_space, __pyx_n_s_error, __pyx_n_s_colors, __pyx_n_s_increase, __pyx_n_s_alphas); if (unlikely(!__pyx_tuple__561)) __PYX_ERR(0, 9198, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__561); __Pyx_GIVEREF(__pyx_tuple__561); __pyx_codeobj__341 = (PyObject*)__Pyx_PyCode_New(11, 0, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__561, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_get_colors_and_alphas, 9198, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__341)) __PYX_ERR(0, 9198, __pyx_L1_error) /* … */ __Pyx_TraceLine(9198,0,__PYX_ERR(0, 9198, __pyx_L1_error)) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_298get_colors_and_alphas, 0, __pyx_n_s_get_colors_and_alphas, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__341)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9198, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__562); if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_colors_and_alphas, __pyx_t_8) < 0) __PYX_ERR(0, 9198, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_tuple__562 = PyTuple_Pack(10, Py_None, ((PyObject*)__pyx_n_u_decrease), ((PyObject*)__pyx_float_0_1), ((PyObject*)__pyx_float_1_0), ((PyObject *)Py_True), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject *)Py_False), ((PyObject*)__pyx_n_u_rgb), ((PyObject*)__pyx_n_u_ignore)); if (unlikely(!__pyx_tuple__562)) __PYX_ERR(0, 9198, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__562); __Pyx_GIVEREF(__pyx_tuple__562);
9199: count,
+9200: cmap=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_decrease))); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_0_1))); values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_float_1_0)));
9201: alpha_direction='decrease',
9202: start_alpha=0.1,
9203: end_alpha=1.0,
+9204: convert_to_named_color=True,
values[5] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+9205: single_color_as_string=False,
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+9206: consider_alpha=False,
values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+9207: ignore_color_names=False,
values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_rgb))); values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_ignore))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_count)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_cmap); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_alpha_direction); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_start_alpha); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_end_alpha); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_convert_to_named_color); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_single_color_as_string); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_consider_alpha); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_ignore_color_names); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_color_space); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_error); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9198, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "get_colors_and_alphas") < 0)) __PYX_ERR(0, 9198, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_count = values[0]; __pyx_v_cmap = values[1]; __pyx_v_alpha_direction = values[2]; __pyx_v_start_alpha = values[3]; __pyx_v_end_alpha = values[4]; __pyx_v_convert_to_named_color = values[5]; __pyx_v_single_color_as_string = values[6]; __pyx_v_consider_alpha = values[7]; __pyx_v_ignore_color_names = values[8]; __pyx_v_color_space = values[9]; __pyx_v_error = values[10]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("get_colors_and_alphas", 0, 1, 11, __pyx_nargs); __PYX_ERR(0, 9198, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.get_colors_and_alphas", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_297get_colors_and_alphas(__pyx_self, __pyx_v_count, __pyx_v_cmap, __pyx_v_alpha_direction, __pyx_v_start_alpha, __pyx_v_end_alpha, __pyx_v_convert_to_named_color, __pyx_v_single_color_as_string, __pyx_v_consider_alpha, __pyx_v_ignore_color_names, __pyx_v_color_space, __pyx_v_error);
9208: color_space='rgb',
9209: error="ignore"
9210: ):
9211: """
9212: Generates a sequence of color codes and alpha (transparency) values.
9213:
9214: Colors can be sourced from a specified Matplotlib colormap or generated
9215: using predefined styles. Alpha values can be arranged in ascending or
9216: descending order to create a gradient effect.
9217:
9218: The function also supports converting color tuples to named colors and
9219: allows for customizing the transparency gradient. Additionally, if only
9220: one color is generated, it can return that color directly as a string
9221: rather than wrapped in a list, for convenience in functions that expect a
9222: single color string.
9223:
9224: Parameters
9225: ----------
9226: count : int or iterable
9227: Specifies the number of colors and alpha values to generate. If an iterable
9228: is provided, its length determines the number of colors and alphas.
9229: cmap : str, optional
9230: The name of a Matplotlib colormap to generate colors. If None, colors are
9231: generated using predefined styles. Defaults to ``None``.
9232: alpha_direction : str, optional
9233: Direction to arrange alpha values for creating a gradient effect. ``increase``
9234: for ascending order, ``decrease`` for descending. Defaults to ``decrease``.
9235: start_alpha : float, optional
9236: The starting alpha value (transparency) in the gradient, between 0 (fully
9237: transparent) and 1 (fully opaque). Defaults to ``0.1``.
9238: end_alpha : float, optional
9239: The ending alpha value in the gradient, between 0 and 1.
9240: Defaults to ``1.0``.
9241: convert_to_named_color : bool, optional
9242: Converts color tuples to the nearest Matplotlib named color. This
9243: conversion applies when exactly one color is generated.
9244: Defaults to ``True``.
9245: single_color_as_string : bool, optional
9246: If True and only one color is generated, returns the color as a string
9247: instead of a list. Useful for functions expecting a single color string.
9248: Defaults to ``False``.
9249: consider_alpha : bool, optional
9250: Includes the alpha channel in the conversion process to named colors.
9251: Applicable only when `convert_to_named_color` is True. This is helpful
9252: when a human-readable color name is preferred over RGB values.
9253: Defaults to ``False``.
9254: ignore_color_names : bool, optional
9255: When True, any input color names (str) are ignored during conversion
9256: to named colors. Useful to exclude specific colors from conversion.
9257: Defaults to ``False``.
9258: color_space : str, optional
9259: The color space used for computing the closeness of colors. Can be
9260: ``rgb`` for RGB color space or ``lab`` for LAB color space, which is more
9261: perceptually uniform. Defaults to ``rgb``.
9262: error : str, optional
9263: Controls the error handling strategy when an invalid color is
9264: encountered during the conversion process. ``raise`` will throw an error,
9265: while ``ignore`` will proceed without error. Defaults to ``ignore``.
9266:
9267: Returns
9268: -------
9269: tuple
9270: A tuple containing either a list of color codes (RGBA or named color strings)
9271: and a corresponding list of alpha values, or a single color code and alpha
9272: value if `single_color_as_string` is True and only one color is generated.
9273:
9274: Examples
9275: --------
9276: Generate 3 random colors with decreasing alpha values:
9277:
9278: >>> get_colors_and_alphas(3)
9279: (['#1f77b4', '#ff7f0e', '#2ca02c'], [1.0, 0.55, 0.1])
9280:
9281: Generate 4 colors from the 'viridis' colormap with increasing alpha values:
9282:
9283: >>> get_colors_and_alphas(4, cmap='viridis', alpha_direction='increase')
9284: (['#440154', '#3b528b', '#21918c', '#5ec962'], [0.1, 0.4, 0.7, 1.0])
9285:
9286: Convert a single generated color to a named color:
9287:
9288: >>> get_colors_and_alphas(1, convert_to_named_color=True)
9289: ('rebeccapurple', [1.0])
9290:
9291: Get a single color as a string instead of a list:
9292:
9293: >>> get_colors_and_alphas(1, single_color_as_string=True)
9294: ('#1f77b4', [1.0])
9295: """
9296:
+9297: if hasattr(count, '__iter__'):
__Pyx_TraceLine(9297,0,__PYX_ERR(0, 9297, __pyx_L1_error)) __pyx_t_1 = __Pyx_HasAttr(__pyx_v_count, __pyx_n_u_iter); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 9297, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+9298: count = len(count)
__Pyx_TraceLine(9298,0,__PYX_ERR(0, 9298, __pyx_L1_error)) __pyx_t_2 = PyObject_Length(__pyx_v_count); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9298, __pyx_L1_error) __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9298, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_count, __pyx_t_3); __pyx_t_3 = 0;
+9299: colors =[]
__Pyx_TraceLine(9299,0,__PYX_ERR(0, 9299, __pyx_L1_error)) __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9299, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_colors = __pyx_t_3; __pyx_t_3 = 0;
+9300: if cmap is not None and cmap not in plt.colormaps():
__Pyx_TraceLine(9300,0,__PYX_ERR(0, 9300, __pyx_L1_error)) __pyx_t_4 = (__pyx_v_cmap != Py_None); if (__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L5_bool_binop_done; } __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_plt); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_colormaps); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_7, 0+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9300, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_v_cmap, __pyx_t_3, Py_NE)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9300, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_1 = __pyx_t_4; __pyx_L5_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+9301: cmap=None
__Pyx_TraceLine(9301,0,__PYX_ERR(0, 9301, __pyx_L1_error)) __Pyx_INCREF(Py_None); __Pyx_DECREF_SET(__pyx_v_cmap, Py_None);
+9302: colors =[cmap] # add it to generate map
__Pyx_TraceLine(9302,0,__PYX_ERR(0, 9302, __pyx_L1_error)) __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9302, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_cmap); __Pyx_GIVEREF(__pyx_v_cmap); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_cmap)) __PYX_ERR(0, 9302, __pyx_L1_error); __Pyx_DECREF_SET(__pyx_v_colors, __pyx_t_3); __pyx_t_3 = 0;
9303: # Generate colors
+9304: if cmap is not None:
__Pyx_TraceLine(9304,0,__PYX_ERR(0, 9304, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_cmap != Py_None); if (__pyx_t_1) { /* … */ goto __pyx_L7; }
+9305: colors = decompose_colormap(cmap, n_colors=count)
__Pyx_TraceLine(9305,0,__PYX_ERR(0, 9305, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_decompose_colormap); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_cmap); __Pyx_GIVEREF(__pyx_v_cmap); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_cmap)) __PYX_ERR(0, 9305, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_n_colors, __pyx_v_count) < 0) __PYX_ERR(0, 9305, __pyx_L1_error) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9305, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_colors, __pyx_t_8); __pyx_t_8 = 0;
9306: else:
+9307: colors += generate_mpl_styles(count, prop='color')
__Pyx_TraceLine(9307,0,__PYX_ERR(0, 9307, __pyx_L1_error)) /*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_generate_mpl_styles); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_count); __Pyx_GIVEREF(__pyx_v_count); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_count)) __PYX_ERR(0, 9307, __pyx_L1_error); __pyx_t_6 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_prop, __pyx_n_u_color) < 0) __PYX_ERR(0, 9307, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_colors, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_colors, __pyx_t_6); __pyx_t_6 = 0; } __pyx_L7:;
9308:
9309: # Generate alphas
+9310: increase = alpha_direction == 'increase'
__Pyx_TraceLine(9310,0,__PYX_ERR(0, 9310, __pyx_L1_error)) __pyx_t_6 = PyObject_RichCompare(__pyx_v_alpha_direction, __pyx_n_u_increase, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9310, __pyx_L1_error) __pyx_v_increase = __pyx_t_6; __pyx_t_6 = 0;
+9311: alphas = generate_alpha_values(count, increase=increase,
__Pyx_TraceLine(9311,0,__PYX_ERR(0, 9311, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_generate_alpha_values); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_count); __Pyx_GIVEREF(__pyx_v_count); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_count)) __PYX_ERR(0, 9311, __pyx_L1_error); __pyx_t_5 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_increase, __pyx_v_increase) < 0) __PYX_ERR(0, 9311, __pyx_L1_error) /* … */ __Pyx_TraceLine(9311,0,__PYX_ERR(0, 9311, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9311, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_alphas = __pyx_t_8; __pyx_t_8 = 0;
+9312: start=start_alpha, end=end_alpha)
__Pyx_TraceLine(9312,0,__PYX_ERR(0, 9312, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_start, __pyx_v_start_alpha) < 0) __PYX_ERR(0, 9311, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_end, __pyx_v_end_alpha) < 0) __PYX_ERR(0, 9311, __pyx_L1_error)
9313:
9314: # Convert tuple colors to named colors if applicable
+9315: if convert_to_named_color:
__Pyx_TraceLine(9315,0,__PYX_ERR(0, 9315, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_convert_to_named_color); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9315, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+9316: colors = colors_to_names(
__Pyx_TraceLine(9316,0,__PYX_ERR(0, 9316, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_colors_to_names); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); /* … */ __Pyx_TraceLine(9317,0,__PYX_ERR(0, 9317, __pyx_L1_error)) __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_v_colors); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); /* … */ __Pyx_TraceLine(9316,0,__PYX_ERR(0, 9316, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9316, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF_SET(__pyx_v_colors, __pyx_t_6); __pyx_t_6 = 0;
+9317: *colors, consider_alpha= consider_alpha,
__pyx_t_3 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9317, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_consider_alpha, __pyx_v_consider_alpha) < 0) __PYX_ERR(0, 9317, __pyx_L1_error)
+9318: ignore_color_names=ignore_color_names,
__Pyx_TraceLine(9318,0,__PYX_ERR(0, 9318, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_ignore_color_names, __pyx_v_ignore_color_names) < 0) __PYX_ERR(0, 9317, __pyx_L1_error)
+9319: color_space= color_space,
__Pyx_TraceLine(9319,0,__PYX_ERR(0, 9319, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_color_space, __pyx_v_color_space) < 0) __PYX_ERR(0, 9317, __pyx_L1_error)
+9320: error= error,
__Pyx_TraceLine(9320,0,__PYX_ERR(0, 9320, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_error, __pyx_v_error) < 0) __PYX_ERR(0, 9317, __pyx_L1_error)
9321: )
9322: # If a single color is requested as a string, return it directly
+9323: if single_color_as_string and len(colors) == 1:
__Pyx_TraceLine(9323,0,__PYX_ERR(0, 9323, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_single_color_as_string); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9323, __pyx_L1_error) if (__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L10_bool_binop_done; } __pyx_t_2 = PyObject_Length(__pyx_v_colors); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9323, __pyx_L1_error) __pyx_t_4 = (__pyx_t_2 == 1); __pyx_t_1 = __pyx_t_4; __pyx_L10_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+9324: if not convert_to_named_color:
__Pyx_TraceLine(9324,0,__PYX_ERR(0, 9324, __pyx_L1_error)) __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_convert_to_named_color); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9324, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_1); if (__pyx_t_4) { /* … */ }
+9325: colors = [closest_color(colors[0], consider_alpha= consider_alpha,
__Pyx_TraceLine(9325,0,__PYX_ERR(0, 9325, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_closest_color); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_colors, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3)) __PYX_ERR(0, 9325, __pyx_L1_error); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_consider_alpha, __pyx_v_consider_alpha) < 0) __PYX_ERR(0, 9325, __pyx_L1_error) /* … */ __Pyx_TraceLine(9325,0,__PYX_ERR(0, 9325, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9325, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_8); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_8)) __PYX_ERR(0, 9325, __pyx_L1_error); __pyx_t_8 = 0; __Pyx_DECREF_SET(__pyx_v_colors, __pyx_t_3); __pyx_t_3 = 0;
+9326: color_space =color_space )]
__Pyx_TraceLine(9326,0,__PYX_ERR(0, 9326, __pyx_L1_error)) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_color_space, __pyx_v_color_space) < 0) __PYX_ERR(0, 9325, __pyx_L1_error)
+9327: colors = colors[0]
__Pyx_TraceLine(9327,0,__PYX_ERR(0, 9327, __pyx_L1_error)) __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_colors, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9327, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF_SET(__pyx_v_colors, __pyx_t_3); __pyx_t_3 = 0;
9328:
+9329: return colors, alphas
__Pyx_TraceLine(9329,0,__PYX_ERR(0, 9329, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9329, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_colors); __Pyx_GIVEREF(__pyx_v_colors); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_colors)) __PYX_ERR(0, 9329, __pyx_L1_error); __Pyx_INCREF(__pyx_v_alphas); __Pyx_GIVEREF(__pyx_v_alphas); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_alphas)) __PYX_ERR(0, 9329, __pyx_L1_error); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
9330:
9331:
+9332: def colors_to_names(*colors, consider_alpha=False, ignore_color_names=False,
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_300colors_to_names(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_299colors_to_names, "\n Converts a sequence of RGB or RGBA colors to their closest named color \n strings. \n \n Optionally ignores input color names and handles colors in specified \n color spaces.\n \n Parameters\n ----------\n *colors : tuple\n A variable number of RGB(A) color tuples or color name strings.\n consider_alpha : bool, optional\n If True, the alpha channel in RGBA colors is considered in the conversion\n process. Defaults to False.\n ignore_color_names : bool, optional\n If True, input strings that are already color names are ignored. \n Defaults to False.\n color_space : str, optional\n Specifies the color space ('rgb' or 'lab') used for color comparison. \n Defaults to 'rgb'.\n error : str, optional\n Error handling strategy when encountering invalid colors. If 'raise', \n errors are raised. Otherwise, errors are ignored. Defaults to 'ignore'.\n \n Returns\n -------\n list\n A list of color name strings corresponding to the input colors.\n\n Examples\n --------\n >>> from gofast.tools.coreutils import colors_to_names\n >>> colors_to_names((0.267004, 0.004874, 0.329415, 1.0), \n (0.127568, 0.566949, 0.550556, 1.0), \n consider_alpha=True)\n ['rebeccapurple', 'mediumseagreen']\n \n >>> colors_to_names('rebeccapurple', ignore_color_names=True)\n []\n \n >>> colors_to_names((123, 234, 45), color_space='lab', error='raise')\n ['limegreen']\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_300colors_to_names = {"colors_to_names", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_300colors_to_names, METH_VARARGS|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_299colors_to_names}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_300colors_to_names(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_consider_alpha = 0; PyObject *__pyx_v_ignore_color_names = 0; PyObject *__pyx_v_color_space = 0; PyObject *__pyx_v_error = 0; PyObject *__pyx_v_colors = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("colors_to_names (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __Pyx_INCREF(__pyx_args); __pyx_v_colors = __pyx_args; { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_consider_alpha,&__pyx_n_s_ignore_color_names,&__pyx_n_s_color_space,&__pyx_n_s_error,0}; PyObject* values[4] = {0,0,0,0}; values[0] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[1] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject*)__pyx_n_u_rgb))); values[3] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)((PyObject*)__pyx_n_u_ignore))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { default: case 0: break; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); if (kw_args > 0 && likely(kw_args <= 4)) { Py_ssize_t index; for (index = 0; index < 4 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9332, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, 0, "colors_to_names") < 0)) __PYX_ERR(0, 9332, __pyx_L3_error) } } else if (unlikely(__pyx_nargs < 0)) { goto __pyx_L5_argtuple_error; } else { } __pyx_v_consider_alpha = values[0]; __pyx_v_ignore_color_names = values[1]; __pyx_v_color_space = values[2]; __pyx_v_error = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("colors_to_names", 0, 0, 0, __pyx_nargs); __PYX_ERR(0, 9332, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_DECREF(__pyx_v_colors); __pyx_v_colors = 0; __Pyx_AddTraceback("gofast.tools.coreutils.colors_to_names", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_299colors_to_names(__pyx_self, __pyx_v_consider_alpha, __pyx_v_ignore_color_names, __pyx_v_color_space, __pyx_v_error, __pyx_v_colors); /* function exit code */ __Pyx_DECREF(__pyx_v_colors); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_6gofast_5tools_9coreutils_299colors_to_names(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_consider_alpha, PyObject *__pyx_v_ignore_color_names, PyObject *__pyx_v_color_space, PyObject *__pyx_v_error, PyObject *__pyx_v_colors) { PyObject *__pyx_v_color_names = NULL; PyObject *__pyx_v_color = NULL; PyObject *__pyx_v_color_name = NULL; PyObject *__pyx_v_e = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__342) __Pyx_TraceCall("colors_to_names", __pyx_f[0], 9332, 0, __PYX_ERR(0, 9332, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("gofast.tools.coreutils.colors_to_names", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_color_names); __Pyx_XDECREF(__pyx_v_color); __Pyx_XDECREF(__pyx_v_color_name); __Pyx_XDECREF(__pyx_v_e); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__563 = PyTuple_Pack(9, __pyx_n_s_consider_alpha, __pyx_n_s_ignore_color_names, __pyx_n_s_color_space, __pyx_n_s_error, __pyx_n_s_colors, __pyx_n_s_color_names, __pyx_n_s_color, __pyx_n_s_color_name, __pyx_n_s_e); if (unlikely(!__pyx_tuple__563)) __PYX_ERR(0, 9332, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__563); __Pyx_GIVEREF(__pyx_tuple__563); /* … */ __Pyx_TraceLine(9332,0,__PYX_ERR(0, 9332, __pyx_L1_error)) __pyx_t_8 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_consider_alpha, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 9332, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_ignore_color_names, ((PyObject *)Py_False)) < 0) __PYX_ERR(0, 9332, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_color_space, ((PyObject*)__pyx_n_u_rgb)) < 0) __PYX_ERR(0, 9332, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_error, ((PyObject*)__pyx_n_u_ignore)) < 0) __PYX_ERR(0, 9332, __pyx_L1_error) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_300colors_to_names, 0, __pyx_n_s_colors_to_names, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__342)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9332, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_5, __pyx_t_8); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_colors_to_names, __pyx_t_5) < 0) __PYX_ERR(0, 9332, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_codeobj__342 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__563, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_colors_to_names, 9332, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__342)) __PYX_ERR(0, 9332, __pyx_L1_error)
9333: color_space='rgb', error='ignore'):
9334: """
9335: Converts a sequence of RGB or RGBA colors to their closest named color
9336: strings.
9337:
9338: Optionally ignores input color names and handles colors in specified
9339: color spaces.
9340:
9341: Parameters
9342: ----------
9343: *colors : tuple
9344: A variable number of RGB(A) color tuples or color name strings.
9345: consider_alpha : bool, optional
9346: If True, the alpha channel in RGBA colors is considered in the conversion
9347: process. Defaults to False.
9348: ignore_color_names : bool, optional
9349: If True, input strings that are already color names are ignored.
9350: Defaults to False.
9351: color_space : str, optional
9352: Specifies the color space ('rgb' or 'lab') used for color comparison.
9353: Defaults to 'rgb'.
9354: error : str, optional
9355: Error handling strategy when encountering invalid colors. If 'raise',
9356: errors are raised. Otherwise, errors are ignored. Defaults to 'ignore'.
9357:
9358: Returns
9359: -------
9360: list
9361: A list of color name strings corresponding to the input colors.
9362:
9363: Examples
9364: --------
9365: >>> from gofast.tools.coreutils import colors_to_names
9366: >>> colors_to_names((0.267004, 0.004874, 0.329415, 1.0),
9367: (0.127568, 0.566949, 0.550556, 1.0),
9368: consider_alpha=True)
9369: ['rebeccapurple', 'mediumseagreen']
9370:
9371: >>> colors_to_names('rebeccapurple', ignore_color_names=True)
9372: []
9373:
9374: >>> colors_to_names((123, 234, 45), color_space='lab', error='raise')
9375: ['limegreen']
9376: """
+9377: color_names = []
__Pyx_TraceLine(9377,0,__PYX_ERR(0, 9377, __pyx_L1_error)) __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9377, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_color_names = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0;
+9378: for color in colors:
__Pyx_TraceLine(9378,0,__PYX_ERR(0, 9378, __pyx_L1_error)) __pyx_t_1 = __pyx_v_colors; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9378, __pyx_L1_error) #endif if (__pyx_t_2 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 9378, __pyx_L1_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_v_color, __pyx_t_3); __pyx_t_3 = 0; /* … */ __Pyx_TraceLine(9378,0,__PYX_ERR(0, 9378, __pyx_L1_error)) __pyx_L3_continue:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+9379: if isinstance(color, str):
__Pyx_TraceLine(9379,0,__PYX_ERR(0, 9379, __pyx_L1_error)) __pyx_t_4 = PyUnicode_Check(__pyx_v_color); if (__pyx_t_4) { /* … */ goto __pyx_L5; }
+9380: if ignore_color_names:
__Pyx_TraceLine(9380,0,__PYX_ERR(0, 9380, __pyx_L1_error)) __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_ignore_color_names); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9380, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+9381: continue
__Pyx_TraceLine(9381,0,__PYX_ERR(0, 9381, __pyx_L1_error)) goto __pyx_L3_continue;
9382: else:
+9383: color_names.append(color) # String color name is found
__Pyx_TraceLine(9383,0,__PYX_ERR(0, 9383, __pyx_L1_error)) /*else*/ { __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_color_names, __pyx_v_color); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 9383, __pyx_L1_error) }
9384: else:
+9385: try:
__Pyx_TraceLine(9385,0,__PYX_ERR(0, 9385, __pyx_L1_error)) /*else*/ { { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L14_try_end; __pyx_L7_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; /* … */ __pyx_L9_except_error:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); goto __pyx_L1_error; __pyx_L8_exception_handled:; __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_XGIVEREF(__pyx_t_8); __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8); __pyx_L14_try_end:; } } __pyx_L5:;
+9386: color_name = closest_color(color, consider_alpha=consider_alpha,
__Pyx_TraceLine(9386,0,__PYX_ERR(0, 9386, __pyx_L7_error)) __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_closest_color); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9386, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9386, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_v_color); __Pyx_GIVEREF(__pyx_v_color); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_color)) __PYX_ERR(0, 9386, __pyx_L7_error); __pyx_t_10 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 9386, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_10); if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_consider_alpha, __pyx_v_consider_alpha) < 0) __PYX_ERR(0, 9386, __pyx_L7_error) /* … */ __Pyx_TraceLine(9386,0,__PYX_ERR(0, 9386, __pyx_L7_error)) __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9386, __pyx_L7_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_color_name, __pyx_t_11); __pyx_t_11 = 0;
+9387: color_space=color_space)
__Pyx_TraceLine(9387,0,__PYX_ERR(0, 9387, __pyx_L7_error)) if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_color_space, __pyx_v_color_space) < 0) __PYX_ERR(0, 9386, __pyx_L7_error)
+9388: color_names.append(color_name)
__Pyx_TraceLine(9388,0,__PYX_ERR(0, 9388, __pyx_L7_error)) __pyx_t_5 = __Pyx_PyList_Append(__pyx_v_color_names, __pyx_v_color_name); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 9388, __pyx_L7_error)
+9389: except Exception as e:
__Pyx_TraceLine(9389,0,__PYX_ERR(0, 9389, __pyx_L9_except_error)) __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_12) { __Pyx_AddTraceback("gofast.tools.coreutils.colors_to_names", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9) < 0) __PYX_ERR(0, 9389, __pyx_L9_except_error) __Pyx_XGOTREF(__pyx_t_11); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __pyx_v_e = __pyx_t_10; /*try:*/ { /* … */ __Pyx_TraceLine(9389,0,__PYX_ERR(0, 9389, __pyx_L20_error)) /*finally:*/ { /*normal exit:*/{ __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; goto __pyx_L21; } __pyx_L20_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __pyx_t_12 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_18); __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20); } __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17); __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14; goto __pyx_L9_except_error; } __pyx_L21:; } __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L8_exception_handled; } goto __pyx_L9_except_error;
+9390: if error == 'raise':
__Pyx_TraceLine(9390,0,__PYX_ERR(0, 9390, __pyx_L20_error)) __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_error, __pyx_n_u_raise, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9390, __pyx_L20_error) if (unlikely(__pyx_t_4)) { /* … */ } }
+9391: raise e
__Pyx_TraceLine(9391,0,__PYX_ERR(0, 9391, __pyx_L20_error)) __Pyx_Raise(__pyx_v_e, 0, 0, 0); __PYX_ERR(0, 9391, __pyx_L20_error)
9392:
+9393: return color_names
__Pyx_TraceLine(9393,0,__PYX_ERR(0, 9393, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_color_names); __pyx_r = __pyx_v_color_names; goto __pyx_L0;
9394:
+9395: def closest_color(rgb_color, consider_alpha=False, color_space='rgb'):
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_302closest_color(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_301closest_color, "\n Finds the closest named CSS4 color to the given RGB(A) color in the specified\n color space, optionally considering the alpha channel.\n\n Parameters\n ----------\n rgb_color : tuple\n A tuple representing the RGB(A) color.\n consider_alpha : bool, optional\n Whether to include the alpha channel in the color closeness calculation.\n Defaults to False.\n color_space : str, optional\n The color space to use when computing color closeness. Can be 'rgb' or 'lab'.\n Defaults to 'rgb'.\n\n Returns\n -------\n str\n The name of the closest CSS4 color.\n\n Raises\n ------\n ValueError\n If an invalid color space is specified.\n\n Examples\n --------\n Find the closest named color to a given RGB color:\n\n >>> from gofast.tools.coreutils import closest_color\n >>> closest_color((123, 234, 45))\n 'forestgreen'\n\n Find the closest named color to a given RGBA color, considering the alpha:\n\n >>> closest_color((123, 234, 45, 0.5), consider_alpha=True)\n 'forestgreen'\n\n Find the closest named color in LAB color space (more perceptually uniform):\n\n >>> closest_color((123, 234, 45), color_space='lab')\n 'limegreen'\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_302closest_color = {"closest_color", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_302closest_color, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_301closest_color}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_302closest_color(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_rgb_color = 0; PyObject *__pyx_v_consider_alpha = 0; PyObject *__pyx_v_color_space = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("closest_color (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_rgb_color,&__pyx_n_s_consider_alpha,&__pyx_n_s_color_space,0}; PyObject* values[3] = {0,0,0}; values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject*)__pyx_n_u_rgb))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_rgb_color)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9395, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_consider_alpha); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9395, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_color_space); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9395, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "closest_color") < 0)) __PYX_ERR(0, 9395, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_rgb_color = values[0]; __pyx_v_consider_alpha = values[1]; __pyx_v_color_space = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("closest_color", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 9395, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.closest_color", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_301closest_color(__pyx_self, __pyx_v_rgb_color, __pyx_v_consider_alpha, __pyx_v_color_space); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_301closest_color(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_rgb_color, PyObject *__pyx_v_consider_alpha, PyObject *__pyx_v_color_space) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *__pyx_cur_scope; PyObject *__pyx_v_color_comparator = NULL; PyObject *__pyx_v_closest_name = NULL; PyObject *__pyx_v_min_dist = NULL; PyObject *__pyx_v_name = NULL; PyObject *__pyx_v_hex_color = NULL; PyObject *__pyx_v_named_color = NULL; PyObject *__pyx_v_dist = NULL; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__344) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 9395, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("closest_color", __pyx_f[0], 9395, 0, __PYX_ERR(0, 9395, __pyx_L1_error)); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_9); __Pyx_AddTraceback("gofast.tools.coreutils.closest_color", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_color_comparator); __Pyx_XDECREF(__pyx_v_closest_name); __Pyx_XDECREF(__pyx_v_min_dist); __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_hex_color); __Pyx_XDECREF(__pyx_v_named_color); __Pyx_XDECREF(__pyx_v_dist); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__564 = PyTuple_Pack(12, __pyx_n_s_rgb_color, __pyx_n_s_consider_alpha, __pyx_n_s_color_space, __pyx_n_s_distance, __pyx_n_s_input_color, __pyx_n_s_color_comparator, __pyx_n_s_closest_name, __pyx_n_s_min_dist, __pyx_n_s_name_2, __pyx_n_s_hex_color, __pyx_n_s_named_color, __pyx_n_s_dist); if (unlikely(!__pyx_tuple__564)) __PYX_ERR(0, 9395, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__564); __Pyx_GIVEREF(__pyx_tuple__564); __pyx_codeobj__344 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 12, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__564, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_closest_color, 9395, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__344)) __PYX_ERR(0, 9395, __pyx_L1_error) /* … */ __Pyx_TraceLine(9395,0,__PYX_ERR(0, 9395, __pyx_L1_error)) __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_302closest_color, 0, __pyx_n_s_closest_color, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__344)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9395, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_tuple__565); if (PyDict_SetItem(__pyx_d, __pyx_n_s_closest_color, __pyx_t_5) < 0) __PYX_ERR(0, 9395, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_tuple__565 = PyTuple_Pack(2, ((PyObject *)Py_False), ((PyObject*)__pyx_n_u_rgb)); if (unlikely(!__pyx_tuple__565)) __PYX_ERR(0, 9395, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__565); __Pyx_GIVEREF(__pyx_tuple__565); /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color { PyObject_HEAD PyObject *__pyx_v_distance; PyObject *__pyx_v_input_color; };
9396: """
9397: Finds the closest named CSS4 color to the given RGB(A) color in the specified
9398: color space, optionally considering the alpha channel.
9399:
9400: Parameters
9401: ----------
9402: rgb_color : tuple
9403: A tuple representing the RGB(A) color.
9404: consider_alpha : bool, optional
9405: Whether to include the alpha channel in the color closeness calculation.
9406: Defaults to False.
9407: color_space : str, optional
9408: The color space to use when computing color closeness. Can be 'rgb' or 'lab'.
9409: Defaults to 'rgb'.
9410:
9411: Returns
9412: -------
9413: str
9414: The name of the closest CSS4 color.
9415:
9416: Raises
9417: ------
9418: ValueError
9419: If an invalid color space is specified.
9420:
9421: Examples
9422: --------
9423: Find the closest named color to a given RGB color:
9424:
9425: >>> from gofast.tools.coreutils import closest_color
9426: >>> closest_color((123, 234, 45))
9427: 'forestgreen'
9428:
9429: Find the closest named color to a given RGBA color, considering the alpha:
9430:
9431: >>> closest_color((123, 234, 45, 0.5), consider_alpha=True)
9432: 'forestgreen'
9433:
9434: Find the closest named color in LAB color space (more perceptually uniform):
9435:
9436: >>> closest_color((123, 234, 45), color_space='lab')
9437: 'limegreen'
9438: """
+9439: if color_space not in ['rgb', 'lab']:
__Pyx_TraceLine(9439,0,__PYX_ERR(0, 9439, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_color_space); __pyx_t_1 = __pyx_v_color_space; __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_rgb, Py_NE)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 9439, __pyx_L1_error) if (__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_lab, Py_NE)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 9439, __pyx_L1_error) __pyx_t_2 = __pyx_t_3; __pyx_L4_bool_binop_done:; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = __pyx_t_2; if (unlikely(__pyx_t_3)) { /* … */ }
+9440: raise ValueError(f"Invalid color space '{color_space}'. Choose 'rgb' or 'lab'.")
__Pyx_TraceLine(9440,0,__PYX_ERR(0, 9440, __pyx_L1_error)) __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_color_space); __pyx_t_4 += 21; __Pyx_GIVEREF(__pyx_kp_u_Invalid_color_space); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_Invalid_color_space); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_v_color_space, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u_Choose_rgb_or_lab); __pyx_t_4 += 25; __Pyx_GIVEREF(__pyx_kp_u_Choose_rgb_or_lab); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u_Choose_rgb_or_lab); __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9440, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 9440, __pyx_L1_error)
9441:
+9442: if ensure_scipy_compatibility():
__Pyx_TraceLine(9442,0,__PYX_ERR(0, 9442, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_ensure_scipy_compatibility); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_6, __pyx_callargs+1-__pyx_t_8, 0+__pyx_t_8); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9442, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 9442, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_3) { /* … */ }
+9443: from scipy.spatial import distance
__Pyx_TraceLine(9443,0,__PYX_ERR(0, 9443, __pyx_L1_error)) __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_distance); __Pyx_GIVEREF(__pyx_n_s_distance); if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_distance)) __PYX_ERR(0, 9443, __pyx_L1_error); __pyx_t_6 = __Pyx_Import(__pyx_n_s_scipy_spatial, __pyx_t_1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_6, __pyx_n_s_distance); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9443, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_distance = __pyx_t_1; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9444: # Adjust input color based on consider_alpha flag
9445:
9446: # Include alpha channel if consider_alpha is True
+9447: input_color = rgb_color[:3 + consider_alpha]
__Pyx_TraceLine(9447,0,__PYX_ERR(0, 9447, __pyx_L1_error)) __pyx_t_6 = __Pyx_PyInt_AddCObj(__pyx_int_3, __pyx_v_consider_alpha, 3, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_rgb_color, 0, 0, NULL, &__pyx_t_6, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9447, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_input_color = __pyx_t_1; __pyx_t_1 = 0;
9448:
9449: # Convert the color to the chosen color space if needed
+9450: if color_space == 'lab':
__Pyx_TraceLine(9450,0,__PYX_ERR(0, 9450, __pyx_L1_error)) __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_color_space, __pyx_n_u_lab, Py_EQ)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 9450, __pyx_L1_error) if (__pyx_t_3) { /* … */ goto __pyx_L7; }
9451: # LAB conversion ignores alpha
+9452: input_color = mcolors.rgb_to_lab(input_color[:3])
__Pyx_TraceLine(9452,0,__PYX_ERR(0, 9452, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_mcolors); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_rgb_to_lab); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 9452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_cur_scope->__pyx_v_input_color, 0, 3, NULL, NULL, &__pyx_slice__343, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = NULL; __pyx_t_8 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_9)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); __pyx_t_8 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_6}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_7, __pyx_callargs+1-__pyx_t_8, 1+__pyx_t_8); __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9452, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_input_color); __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_input_color, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0;
+9453: color_comparator = lambda color: distance.euclidean(
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13closest_color_lambda37(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_13closest_color_lambda37 = {"lambda37", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_13closest_color_lambda37, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13closest_color_lambda37(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_color = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda37 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_color,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_color)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9453, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda37") < 0)) __PYX_ERR(0, 9453, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_color = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda37", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 9453, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.closest_color.lambda37", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda37(__pyx_self, __pyx_v_color);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda37(PyObject *__pyx_self, PyObject *__pyx_v_color) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda37", __pyx_f[0], 9453, 0, __PYX_ERR(0, 9453, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_distance)) { __Pyx_RaiseClosureNameError("distance"); __PYX_ERR(0, 9453, __pyx_L1_error) }
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_distance, __pyx_n_s_euclidean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9453, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_AddTraceback("gofast.tools.coreutils.closest_color.lambda37", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(9453,0,__PYX_ERR(0, 9453, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_13closest_color_lambda37, 0, __pyx_n_s_closest_color_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9453, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_color_comparator = __pyx_t_1;
__pyx_t_1 = 0;
+9454: mcolors.rgb_to_lab(color[:3]), input_color)
__Pyx_TraceLine(9454,0,__PYX_ERR(0, 9454, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_mcolors); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_rgb_to_lab); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_color, 0, 3, NULL, NULL, &__pyx_slice__343, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 9454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_6 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4}; __pyx_t_3 = __Pyx_PyObject_FastCall(__pyx_t_5, __pyx_callargs+1-__pyx_t_7, 1+__pyx_t_7); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9454, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } if (unlikely(!__pyx_cur_scope->__pyx_v_input_color)) { __Pyx_RaiseClosureNameError("input_color"); __PYX_ERR(0, 9454, __pyx_L1_error) } __pyx_t_5 = NULL; __pyx_t_7 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_7 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_3, __pyx_cur_scope->__pyx_v_input_color}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_7, 2+__pyx_t_7); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9453, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* … */ __pyx_slice__343 = PySlice_New(Py_None, __pyx_int_3, Py_None); if (unlikely(!__pyx_slice__343)) __PYX_ERR(0, 9454, __pyx_L1_error) __Pyx_GOTREF(__pyx_slice__343); __Pyx_GIVEREF(__pyx_slice__343);
9455: else: # RGB or RGBA
+9456: color_comparator = lambda color: distance.euclidean(
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13closest_color_1lambda38(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_13closest_color_1lambda38 = {"lambda38", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_13closest_color_1lambda38, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_13closest_color_1lambda38(PyObject *__pyx_self,
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
PyObject *__pyx_v_color = 0;
#if !CYTHON_METH_FASTCALL
CYTHON_UNUSED Py_ssize_t __pyx_nargs;
#endif
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("lambda38 (wrapper)", 0);
#if !CYTHON_METH_FASTCALL
#if CYTHON_ASSUME_SAFE_MACROS
__pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
#else
__pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
#endif
#endif
__pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
{
PyObject **__pyx_pyargnames[] = {&__pyx_n_s_color,0};
PyObject* values[1] = {0};
if (__pyx_kwds) {
Py_ssize_t kw_args;
switch (__pyx_nargs) {
case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds);
switch (__pyx_nargs) {
case 0:
if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_color)) != 0)) {
(void)__Pyx_Arg_NewRef_FASTCALL(values[0]);
kw_args--;
}
else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9456, __pyx_L3_error)
else goto __pyx_L5_argtuple_error;
}
if (unlikely(kw_args > 0)) {
const Py_ssize_t kwd_pos_args = __pyx_nargs;
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "lambda38") < 0)) __PYX_ERR(0, 9456, __pyx_L3_error)
}
} else if (unlikely(__pyx_nargs != 1)) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0);
}
__pyx_v_color = values[0];
}
goto __pyx_L6_skip;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("lambda38", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 9456, __pyx_L3_error)
__pyx_L6_skip:;
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_AddTraceback("gofast.tools.coreutils.closest_color.lambda38", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_lambda_funcdef_lambda38(__pyx_self, __pyx_v_color);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
/* function exit code */
{
Py_ssize_t __pyx_temp;
for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
__Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]);
}
}
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_lambda_funcdef_lambda38(PyObject *__pyx_self, PyObject *__pyx_v_color) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *__pyx_outer_scope;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_39_closest_color *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("lambda38", __pyx_f[0], 9456, 0, __PYX_ERR(0, 9456, __pyx_L1_error));
__Pyx_XDECREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_v_distance)) { __Pyx_RaiseClosureNameError("distance"); __PYX_ERR(0, 9456, __pyx_L1_error) }
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_distance, __pyx_n_s_euclidean); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9456, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_5);
__Pyx_AddTraceback("gofast.tools.coreutils.closest_color.lambda38", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(9456,0,__PYX_ERR(0, 9456, __pyx_L1_error))
/*else*/ {
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_13closest_color_1lambda38, 0, __pyx_n_s_closest_color_locals_lambda, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9456, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_color_comparator = __pyx_t_1;
__pyx_t_1 = 0;
}
__pyx_L7:;
+9457: color[:len(input_color)], input_color)
__Pyx_TraceLine(9457,0,__PYX_ERR(0, 9457, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_input_color)) { __Pyx_RaiseClosureNameError("input_color"); __PYX_ERR(0, 9457, __pyx_L1_error) } __pyx_t_3 = __pyx_cur_scope->__pyx_v_input_color; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9457, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_color, 0, __pyx_t_4, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9457, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (unlikely(!__pyx_cur_scope->__pyx_v_input_color)) { __Pyx_RaiseClosureNameError("input_color"); __PYX_ERR(0, 9457, __pyx_L1_error) } __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_3, __pyx_cur_scope->__pyx_v_input_color}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9456, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
9458:
9459: # Compute the closeness of each named color to the given color
+9460: closest_name = None
__Pyx_TraceLine(9460,0,__PYX_ERR(0, 9460, __pyx_L1_error)) __Pyx_INCREF(Py_None); __pyx_v_closest_name = Py_None;
+9461: min_dist = float('inf')
__Pyx_TraceLine(9461,0,__PYX_ERR(0, 9461, __pyx_L1_error)) __pyx_t_10 = __Pyx_PyUnicode_AsDouble(__pyx_n_u_inf); if (unlikely(__pyx_t_10 == ((double)((double)-1)) && PyErr_Occurred())) __PYX_ERR(0, 9461, __pyx_L1_error) __pyx_t_1 = PyFloat_FromDouble(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_min_dist = __pyx_t_1; __pyx_t_1 = 0;
+9462: for name, hex_color in mcolors.CSS4_COLORS.items():
__Pyx_TraceLine(9462,0,__PYX_ERR(0, 9462, __pyx_L1_error)) __pyx_t_4 = 0; __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_mcolors); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 9462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_CSS4_COLORS); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(__pyx_t_6 == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 9462, __pyx_L1_error) } __pyx_t_7 = __Pyx_dict_iterator(__pyx_t_6, 0, __pyx_n_s_items, (&__pyx_t_11), (&__pyx_t_8)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 9462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_7; __pyx_t_7 = 0; while (1) { __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_11, &__pyx_t_4, &__pyx_t_7, &__pyx_t_6, NULL, __pyx_t_8); if (unlikely(__pyx_t_12 == 0)) break; if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 9462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF_SET(__pyx_v_hex_color, __pyx_t_6); __pyx_t_6 = 0;
9463: # Adjust based on input_color length
+9464: named_color = mcolors.to_rgba(hex_color)[:len(input_color)]
__Pyx_TraceLine(9464,0,__PYX_ERR(0, 9464, __pyx_L1_error)) __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_mcolors); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 9464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_to_rgba); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = NULL; __pyx_t_12 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_7)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_12 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_hex_color}; __pyx_t_6 = __Pyx_PyObject_FastCall(__pyx_t_9, __pyx_callargs+1-__pyx_t_12, 1+__pyx_t_12); __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_t_9 = __pyx_cur_scope->__pyx_v_input_color; __Pyx_INCREF(__pyx_t_9); __pyx_t_13 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9464, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = __Pyx_PyObject_GetSlice(__pyx_t_6, 0, __pyx_t_13, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9464, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF_SET(__pyx_v_named_color, __pyx_t_9); __pyx_t_9 = 0;
+9465: dist = color_comparator(named_color)
__Pyx_TraceLine(9465,0,__PYX_ERR(0, 9465, __pyx_L1_error)) __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_v_color_comparator, __pyx_v_named_color); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_XDECREF_SET(__pyx_v_dist, __pyx_t_9); __pyx_t_9 = 0;
+9466: if dist < min_dist:
__Pyx_TraceLine(9466,0,__PYX_ERR(0, 9466, __pyx_L1_error)) __pyx_t_9 = PyObject_RichCompare(__pyx_v_dist, __pyx_v_min_dist, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 9466, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 9466, __pyx_L1_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; if (__pyx_t_3) { /* … */ } } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+9467: min_dist = dist
__Pyx_TraceLine(9467,0,__PYX_ERR(0, 9467, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_dist); __Pyx_DECREF_SET(__pyx_v_min_dist, __pyx_v_dist);
+9468: closest_name = name
__Pyx_TraceLine(9468,0,__PYX_ERR(0, 9468, __pyx_L1_error)) __Pyx_INCREF(__pyx_v_name); __Pyx_DECREF_SET(__pyx_v_closest_name, __pyx_v_name);
9469:
+9470: return closest_name
__Pyx_TraceLine(9470,0,__PYX_ERR(0, 9470, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_closest_name); __pyx_r = __pyx_v_closest_name; goto __pyx_L0;
9471:
+9472: def check_uniform_type(
/* Python wrapper */ static PyObject *__pyx_pw_6gofast_5tools_9coreutils_304check_uniform_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_6gofast_5tools_9coreutils_303check_uniform_type, "\n Checks whether elements in `values` are of uniform type. \n \n Optionally comparing them against another set of items or converting all \n values to a target type. Can return a callable for deferred execution of \n the specified logic.Function is useful for validating data uniformity, \n especially before performing operations that assume homogeneity of the \n input types.\n \n\n Parameters\n ----------\n values : Iterable[Any] or Any\n An iterable containing items to check. If a non-iterable item is provided,\n it is treated as a single-element iterable.\n items_to_compare : Iterable[Any] or Any, optional\n An iterable of items to compare against `values`. If specified, the\n `comparison_method` is used to perform the comparison.\n raise_exception : bool, default True\n If True, raises an exception when a uniform type is not found or other\n constraints are not met. Otherwise, issues a warning.\n convert_values : bool, default False\n If True, tries to convert all `values` to `target_type`. Requires\n `target_type` to be specified.\n return_types : bool, default False\n If True, returns the types of the items in `values`.\n target_type : type, optional\n The target type to which `values` should be converted if `convert_values`\n is True.\n allow_mismatch : bool, default True\n If False, requires all values to be of identical types; otherwise,\n allows type mismatch.\n infer_types : bool, default False\n If True and different types are found, returns the types of each item\n in `values` in order.\n comparison_method : str, default 'intersection'\n The method used to compare `values` against `items_to_compare`. Must\n be one of the set comparison methods ('difference', 'intersection', etc.).\n custom_conversion_func : Callable[[Any], Any], optional\n A custom function for convertin""g items in `values` to another type.\n return_func : bool, default False\n If True, returns a callable that encapsulates the logic based on the \n other parameters.\n\n Returns\n -------\n Union[bool, List[type], Tuple[Iterable[Any], List[type]], Callable]\n The result based on the specified parameters. This can be: \n - A boolean indicating whether all values are of the same type.\n - The common type of all values if `return_types` is True.\n - A tuple containing the converted values and their types if `convert_values`\n and `return_types` are both True.\n - a callable encapsulating the specified logic for deferred execution.\n \n Examples\n --------\n >>> from gofast.tools.coreutils import check_uniform_type\n >>> check_uniform_type([1, 2, 3])\n True\n\n >>> check_uniform_type([1, '2', 3], allow_mismatch=False, raise_exception=False)\n False\n\n >>> deferred_check = check_uniform_type([1, 2, '3'], convert_values=True, \n ... target_type=int, return_func=True)\n >>> deferred_check()\n [1, 2, 3]\n\n Notes\n -----\n The function is designed to be flexible, supporting immediate or deferred execution,\n with options for type conversion and detailed type information retrieval.\n "); static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_304check_uniform_type = {"check_uniform_type", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_6gofast_5tools_9coreutils_304check_uniform_type, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_6gofast_5tools_9coreutils_303check_uniform_type}; static PyObject *__pyx_pw_6gofast_5tools_9coreutils_304check_uniform_type(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_values = 0; PyObject *__pyx_v_items_to_compare = 0; PyObject *__pyx_v_raise_exception = 0; PyObject *__pyx_v_convert_values = 0; PyObject *__pyx_v_return_types = 0; PyTypeObject *__pyx_v_target_type = 0; PyObject *__pyx_v_allow_mismatch = 0; PyObject *__pyx_v_infer_types = 0; PyObject *__pyx_v_comparison_method = 0; PyObject *__pyx_v_custom_conversion_func = 0; PyObject *__pyx_v_return_func = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("check_uniform_type (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_values,&__pyx_n_s_items_to_compare,&__pyx_n_s_raise_exception,&__pyx_n_s_convert_values,&__pyx_n_s_return_types,&__pyx_n_s_target_type,&__pyx_n_s_allow_mismatch,&__pyx_n_s_infer_types,&__pyx_n_s_comparison_method,&__pyx_n_s_custom_conversion_func,&__pyx_n_s_return_func,0}; PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ static PyObject *__pyx_pf_6gofast_5tools_9coreutils_303check_uniform_type(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_values, PyObject *__pyx_v_items_to_compare, PyObject *__pyx_v_raise_exception, PyObject *__pyx_v_convert_values, PyObject *__pyx_v_return_types, PyTypeObject *__pyx_v_target_type, PyObject *__pyx_v_allow_mismatch, PyObject *__pyx_v_infer_types, PyObject *__pyx_v_comparison_method, PyObject *__pyx_v_custom_conversion_func, PyObject *__pyx_v_return_func) { struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type *__pyx_cur_scope; PyObject *__pyx_v_operation = 0; PyObject *__pyx_r = NULL; __Pyx_TraceDeclarations __Pyx_TraceFrameInit(__pyx_codeobj__347) __pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 9472, __pyx_L1_error) } else { __Pyx_GOTREF((PyObject *)__pyx_cur_scope); } __Pyx_TraceCall("check_uniform_type", __pyx_f[0], 9472, 0, __PYX_ERR(0, 9472, __pyx_L1_error)); __pyx_cur_scope->__pyx_v_values = __pyx_v_values; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_values); __pyx_cur_scope->__pyx_v_items_to_compare = __pyx_v_items_to_compare; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_items_to_compare); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_items_to_compare); __pyx_cur_scope->__pyx_v_raise_exception = __pyx_v_raise_exception; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_raise_exception); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_raise_exception); __pyx_cur_scope->__pyx_v_convert_values = __pyx_v_convert_values; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_convert_values); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_convert_values); __pyx_cur_scope->__pyx_v_return_types = __pyx_v_return_types; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_return_types); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_return_types); __pyx_cur_scope->__pyx_v_target_type = __pyx_v_target_type; __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_target_type); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_target_type); __pyx_cur_scope->__pyx_v_allow_mismatch = __pyx_v_allow_mismatch; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_allow_mismatch); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_allow_mismatch); __pyx_cur_scope->__pyx_v_infer_types = __pyx_v_infer_types; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_infer_types); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_infer_types); __pyx_cur_scope->__pyx_v_comparison_method = __pyx_v_comparison_method; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_comparison_method); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_comparison_method); __pyx_cur_scope->__pyx_v_custom_conversion_func = __pyx_v_custom_conversion_func; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_custom_conversion_func); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_custom_conversion_func); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("gofast.tools.coreutils.check_uniform_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_operation); __Pyx_DECREF((PyObject *)__pyx_cur_scope); __Pyx_XGIVEREF(__pyx_r); __Pyx_TraceReturn(__pyx_r, 0); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__566 = PyTuple_Pack(13, __pyx_n_s_values, __pyx_n_s_items_to_compare, __pyx_n_s_raise_exception, __pyx_n_s_convert_values, __pyx_n_s_return_types, __pyx_n_s_target_type, __pyx_n_s_allow_mismatch, __pyx_n_s_infer_types, __pyx_n_s_comparison_method, __pyx_n_s_custom_conversion_func, __pyx_n_s_return_func, __pyx_n_s_operation, __pyx_n_s_operation); if (unlikely(!__pyx_tuple__566)) __PYX_ERR(0, 9472, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__566); __Pyx_GIVEREF(__pyx_tuple__566); __pyx_codeobj__347 = (PyObject*)__Pyx_PyCode_New(11, 0, 0, 13, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__566, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_check_uniform_type, 9472, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__347)) __PYX_ERR(0, 9472, __pyx_L1_error) /* … */ __Pyx_TraceLine(9472,0,__PYX_ERR(0, 9472, __pyx_L1_error)) __pyx_t_5 = __Pyx_PyDict_NewPresized(12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 9472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_values, __pyx_kp_s_Union_Iterable_Any_Any) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_items_to_compare, __pyx_kp_s_Union_Iterable_Any_Any) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_raise_exception, __pyx_n_s_bool) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_convert_values, __pyx_n_s_bool) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_types, __pyx_n_s_bool) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_target_type, __pyx_n_s_type_2) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_allow_mismatch, __pyx_n_s_bool) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_infer_types, __pyx_n_s_bool) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_comparison_method, __pyx_n_s_str_2) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_custom_conversion_func, __pyx_kp_s_F_Any) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return_func, __pyx_n_s_bool) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_return, __pyx_kp_s_Union_bool_List_type_Tuple_Itera) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_304check_uniform_type, 0, __pyx_n_s_check_uniform_type, NULL, __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__347)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 9472, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_tuple__567); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_5); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_uniform_type, __pyx_t_8) < 0) __PYX_ERR(0, 9472, __pyx_L1_error) __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; /* … */ struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type { PyObject_HEAD PyObject *__pyx_v_allow_mismatch; PyObject *__pyx_v_comparison_method; PyObject *__pyx_v_convert_values; PyObject *__pyx_v_custom_conversion_func; PyObject *__pyx_v_infer_types; PyObject *__pyx_v_items_to_compare; PyObject *__pyx_v_raise_exception; PyObject *__pyx_v_return_types; PyTypeObject *__pyx_v_target_type; PyObject *__pyx_v_values; };
9473: values: Union[Iterable[Any], Any],
+9474: items_to_compare: Union[Iterable[Any], Any] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+9475: raise_exception: bool = True,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+9476: convert_values: bool = False,
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+9477: return_types: bool = False,
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False)));
+9478: target_type: type = None,
values[5] = __Pyx_Arg_NewRef_FASTCALL((PyObject *)((PyTypeObject*)Py_None));
+9479: allow_mismatch: bool = True,
values[6] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_True)));
+9480: infer_types: bool = False,
values[7] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); values[8] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)((PyObject*)__pyx_n_u_intersection)));
9481: comparison_method: str = 'intersection',
+9482: custom_conversion_func: _F[Any] = None,
values[9] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None));
+9483: return_func: bool = False
values[10] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)((PyObject *)Py_False))); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_values)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_items_to_compare); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_raise_exception); if (value) { values[2] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_convert_values); if (value) { values[3] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_types); if (value) { values[4] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 5: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_target_type); if (value) { values[5] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 6: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_allow_mismatch); if (value) { values[6] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 7: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_infer_types); if (value) { values[7] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 8: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_comparison_method); if (value) { values[8] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 9: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_custom_conversion_func); if (value) { values[9] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 10: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_return_func); if (value) { values[10] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 9472, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "check_uniform_type") < 0)) __PYX_ERR(0, 9472, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 11: values[10] = __Pyx_Arg_FASTCALL(__pyx_args, 10); CYTHON_FALLTHROUGH; case 10: values[9] = __Pyx_Arg_FASTCALL(__pyx_args, 9); CYTHON_FALLTHROUGH; case 9: values[8] = __Pyx_Arg_FASTCALL(__pyx_args, 8); CYTHON_FALLTHROUGH; case 8: values[7] = __Pyx_Arg_FASTCALL(__pyx_args, 7); CYTHON_FALLTHROUGH; case 7: values[6] = __Pyx_Arg_FASTCALL(__pyx_args, 6); CYTHON_FALLTHROUGH; case 6: values[5] = __Pyx_Arg_FASTCALL(__pyx_args, 5); CYTHON_FALLTHROUGH; case 5: values[4] = __Pyx_Arg_FASTCALL(__pyx_args, 4); CYTHON_FALLTHROUGH; case 4: values[3] = __Pyx_Arg_FASTCALL(__pyx_args, 3); CYTHON_FALLTHROUGH; case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_values = values[0]; __pyx_v_items_to_compare = values[1]; __pyx_v_raise_exception = values[2]; __pyx_v_convert_values = values[3]; __pyx_v_return_types = values[4]; __pyx_v_target_type = ((PyTypeObject*)values[5]); __pyx_v_allow_mismatch = values[6]; __pyx_v_infer_types = values[7]; __pyx_v_comparison_method = ((PyObject*)values[8]); __pyx_v_custom_conversion_func = values[9]; __pyx_v_return_func = values[10]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("check_uniform_type", 0, 1, 11, __pyx_nargs); __PYX_ERR(0, 9472, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("gofast.tools.coreutils.check_uniform_type", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_target_type), (&PyType_Type), 1, "target_type", 1))) __PYX_ERR(0, 9478, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_comparison_method), (&PyUnicode_Type), 0, "comparison_method", 1))) __PYX_ERR(0, 9481, __pyx_L1_error) __pyx_r = __pyx_pf_6gofast_5tools_9coreutils_303check_uniform_type(__pyx_self, __pyx_v_values, __pyx_v_items_to_compare, __pyx_v_raise_exception, __pyx_v_convert_values, __pyx_v_return_types, __pyx_v_target_type, __pyx_v_allow_mismatch, __pyx_v_infer_types, __pyx_v_comparison_method, __pyx_v_custom_conversion_func, __pyx_v_return_func);
9484: ) -> Union[bool, List[type], Tuple[Iterable[Any], List[type]], _F]:
9485: """
9486: Checks whether elements in `values` are of uniform type.
9487:
9488: Optionally comparing them against another set of items or converting all
9489: values to a target type. Can return a callable for deferred execution of
9490: the specified logic.Function is useful for validating data uniformity,
9491: especially before performing operations that assume homogeneity of the
9492: input types.
9493:
9494:
9495: Parameters
9496: ----------
9497: values : Iterable[Any] or Any
9498: An iterable containing items to check. If a non-iterable item is provided,
9499: it is treated as a single-element iterable.
9500: items_to_compare : Iterable[Any] or Any, optional
9501: An iterable of items to compare against `values`. If specified, the
9502: `comparison_method` is used to perform the comparison.
9503: raise_exception : bool, default True
9504: If True, raises an exception when a uniform type is not found or other
9505: constraints are not met. Otherwise, issues a warning.
9506: convert_values : bool, default False
9507: If True, tries to convert all `values` to `target_type`. Requires
9508: `target_type` to be specified.
9509: return_types : bool, default False
9510: If True, returns the types of the items in `values`.
9511: target_type : type, optional
9512: The target type to which `values` should be converted if `convert_values`
9513: is True.
9514: allow_mismatch : bool, default True
9515: If False, requires all values to be of identical types; otherwise,
9516: allows type mismatch.
9517: infer_types : bool, default False
9518: If True and different types are found, returns the types of each item
9519: in `values` in order.
9520: comparison_method : str, default 'intersection'
9521: The method used to compare `values` against `items_to_compare`. Must
9522: be one of the set comparison methods ('difference', 'intersection', etc.).
9523: custom_conversion_func : Callable[[Any], Any], optional
9524: A custom function for converting items in `values` to another type.
9525: return_func : bool, default False
9526: If True, returns a callable that encapsulates the logic based on the
9527: other parameters.
9528:
9529: Returns
9530: -------
9531: Union[bool, List[type], Tuple[Iterable[Any], List[type]], Callable]
9532: The result based on the specified parameters. This can be:
9533: - A boolean indicating whether all values are of the same type.
9534: - The common type of all values if `return_types` is True.
9535: - A tuple containing the converted values and their types if `convert_values`
9536: and `return_types` are both True.
9537: - a callable encapsulating the specified logic for deferred execution.
9538:
9539: Examples
9540: --------
9541: >>> from gofast.tools.coreutils import check_uniform_type
9542: >>> check_uniform_type([1, 2, 3])
9543: True
9544:
9545: >>> check_uniform_type([1, '2', 3], allow_mismatch=False, raise_exception=False)
9546: False
9547:
9548: >>> deferred_check = check_uniform_type([1, 2, '3'], convert_values=True,
9549: ... target_type=int, return_func=True)
9550: >>> deferred_check()
9551: [1, 2, 3]
9552:
9553: Notes
9554: -----
9555: The function is designed to be flexible, supporting immediate or deferred execution,
9556: with options for type conversion and detailed type information retrieval.
9557: """
+9558: def operation():
/* Python wrapper */
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18check_uniform_type_1operation(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_6gofast_5tools_9coreutils_18check_uniform_type_1operation = {"operation", (PyCFunction)__pyx_pw_6gofast_5tools_9coreutils_18check_uniform_type_1operation, METH_NOARGS, 0};
static PyObject *__pyx_pw_6gofast_5tools_9coreutils_18check_uniform_type_1operation(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("operation (wrapper)", 0);
__pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
__pyx_r = __pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_operation(__pyx_self);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_2generator14(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
/* … */
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_operation(PyObject *__pyx_self) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type *__pyx_cur_scope;
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type *__pyx_outer_scope;
PyObject *__pyx_v_val_list = NULL;
PyObject *__pyx_v_comp_list = NULL;
PyObject *__pyx_v_val_types = NULL;
PyObject *__pyx_v_comp_types = NULL;
PyObject *__pyx_v_common_types = NULL;
PyObject *__pyx_v_converted_values = NULL;
PyObject *__pyx_v_e = NULL;
PyObject *__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_2generator14 = 0;
PyObject *__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_5generator15 = 0;
PyObject *__pyx_9genexpr86__pyx_v_v = NULL;
PyObject *__pyx_9genexpr87__pyx_v_v = NULL;
PyObject *__pyx_9genexpr88__pyx_v_v = NULL;
PyObject *__pyx_9genexpr89__pyx_v_v = NULL;
PyObject *__pyx_r = NULL;
__Pyx_TraceDeclarations
__pyx_outer_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_40_check_uniform_type *) __Pyx_CyFunction_GetClosure(__pyx_self);
__pyx_cur_scope = __pyx_outer_scope;
__Pyx_TraceCall("operation", __pyx_f[0], 9558, 0, __PYX_ERR(0, 9558, __pyx_L1_error));
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_11);
__Pyx_XDECREF(__pyx_t_12);
__Pyx_AddTraceback("gofast.tools.coreutils.check_uniform_type.operation", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_val_list);
__Pyx_XDECREF(__pyx_v_comp_list);
__Pyx_XDECREF(__pyx_v_val_types);
__Pyx_XDECREF(__pyx_v_comp_types);
__Pyx_XDECREF(__pyx_v_common_types);
__Pyx_XDECREF(__pyx_v_converted_values);
__Pyx_XDECREF(__pyx_v_e);
__Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_2generator14);
__Pyx_XDECREF(__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_5generator15);
__Pyx_XDECREF(__pyx_9genexpr86__pyx_v_v);
__Pyx_XDECREF(__pyx_9genexpr87__pyx_v_v);
__Pyx_XDECREF(__pyx_9genexpr88__pyx_v_v);
__Pyx_XDECREF(__pyx_9genexpr89__pyx_v_v);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__pyx_tuple__348 = PyTuple_Pack(14, __pyx_n_s_val_list, __pyx_n_s_comp_list, __pyx_n_s_val_types, __pyx_n_s_comp_types, __pyx_n_s_common_types, __pyx_n_s_converted_values, __pyx_n_s_e, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_genexpr, __pyx_n_s_v, __pyx_n_s_v, __pyx_n_s_v, __pyx_n_s_v); if (unlikely(!__pyx_tuple__348)) __PYX_ERR(0, 9558, __pyx_L1_error)
__Pyx_GOTREF(__pyx_tuple__348);
__Pyx_GIVEREF(__pyx_tuple__348);
/* … */
__Pyx_TraceLine(9558,0,__PYX_ERR(0, 9558, __pyx_L1_error))
__pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_6gofast_5tools_9coreutils_18check_uniform_type_1operation, 0, __pyx_n_s_check_uniform_type_locals_operat_2, ((PyObject*)__pyx_cur_scope), __pyx_n_s_gofast_tools_coreutils, __pyx_d, ((PyObject *)__pyx_codeobj__349)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9558, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_operation = __pyx_t_1;
__pyx_t_1 = 0;
__pyx_codeobj__349 = (PyObject*)__Pyx_PyCode_New(0, 0, 0, 14, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__348, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_gofast_tools_coreutils_pyx, __pyx_n_s_operation, 9558, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__349)) __PYX_ERR(0, 9558, __pyx_L1_error)
9559: # Convert values and items_to_compare to lists if
9560: # they're not already iterable
+9561: if isinstance(values, Iterable) and not isinstance(values, str):
__Pyx_TraceLine(9561,0,__PYX_ERR(0, 9561, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 9561, __pyx_L1_error) } __pyx_t_2 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9561, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = PyObject_IsInstance(__pyx_t_2, __pyx_t_3); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 9561, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L4_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 9561, __pyx_L1_error) } __pyx_t_3 = __pyx_cur_scope->__pyx_v_values; __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = PyUnicode_Check(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_5 = (!__pyx_t_4); __pyx_t_1 = __pyx_t_5; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+9562: val_list = list(values)
__Pyx_TraceLine(9562,0,__PYX_ERR(0, 9562, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 9562, __pyx_L1_error) } __pyx_t_3 = PySequence_List(__pyx_cur_scope->__pyx_v_values); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9562, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_val_list = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
9563: else:
+9564: val_list = [values]
__Pyx_TraceLine(9564,0,__PYX_ERR(0, 9564, __pyx_L1_error)) /*else*/ { if (unlikely(!__pyx_cur_scope->__pyx_v_values)) { __Pyx_RaiseClosureNameError("values"); __PYX_ERR(0, 9564, __pyx_L1_error) } __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9564, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_values); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_values); if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_values)) __PYX_ERR(0, 9564, __pyx_L1_error); __pyx_v_val_list = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; } __pyx_L3:;
9565:
+9566: if items_to_compare is not None:
__Pyx_TraceLine(9566,0,__PYX_ERR(0, 9566, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_items_to_compare)) { __Pyx_RaiseClosureNameError("items_to_compare"); __PYX_ERR(0, 9566, __pyx_L1_error) } __pyx_t_1 = (__pyx_cur_scope->__pyx_v_items_to_compare != Py_None); if (__pyx_t_1) { /* … */ goto __pyx_L6; }
+9567: if isinstance(items_to_compare, Iterable) and not isinstance(
__Pyx_TraceLine(9567,0,__PYX_ERR(0, 9567, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_items_to_compare)) { __Pyx_RaiseClosureNameError("items_to_compare"); __PYX_ERR(0, 9567, __pyx_L1_error) } __pyx_t_3 = __pyx_cur_scope->__pyx_v_items_to_compare; __Pyx_INCREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = PyObject_IsInstance(__pyx_t_3, __pyx_t_2); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 9567, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L8_bool_binop_done; } /* … */ __Pyx_TraceLine(9567,0,__PYX_ERR(0, 9567, __pyx_L1_error)) __pyx_t_4 = (!__pyx_t_5); __pyx_t_1 = __pyx_t_4; __pyx_L8_bool_binop_done:; if (__pyx_t_1) { /* … */ goto __pyx_L7; }
+9568: items_to_compare, str):
__Pyx_TraceLine(9568,0,__PYX_ERR(0, 9568, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_items_to_compare)) { __Pyx_RaiseClosureNameError("items_to_compare"); __PYX_ERR(0, 9568, __pyx_L1_error) } __pyx_t_2 = __pyx_cur_scope->__pyx_v_items_to_compare; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = PyUnicode_Check(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+9569: comp_list = list(items_to_compare)
__Pyx_TraceLine(9569,0,__PYX_ERR(0, 9569, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_items_to_compare)) { __Pyx_RaiseClosureNameError("items_to_compare"); __PYX_ERR(0, 9569, __pyx_L1_error) } __pyx_t_2 = PySequence_List(__pyx_cur_scope->__pyx_v_items_to_compare); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_comp_list = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
9570: else:
+9571: comp_list = [items_to_compare]
__Pyx_TraceLine(9571,0,__PYX_ERR(0, 9571, __pyx_L1_error)) /*else*/ { if (unlikely(!__pyx_cur_scope->__pyx_v_items_to_compare)) { __Pyx_RaiseClosureNameError("items_to_compare"); __PYX_ERR(0, 9571, __pyx_L1_error) } __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9571, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_items_to_compare); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_items_to_compare); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_items_to_compare)) __PYX_ERR(0, 9571, __pyx_L1_error); __pyx_v_comp_list = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; } __pyx_L7:;
9572: else:
+9573: comp_list = []
__Pyx_TraceLine(9573,0,__PYX_ERR(0, 9573, __pyx_L1_error)) /*else*/ { __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9573, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_comp_list = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; } __pyx_L6:;
9574:
9575: # Extract types
+9576: val_types = set(type(v) for v in val_list)
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_9operation_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_41_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_41_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_41_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_41_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_41_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 9576, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_2generator14, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_check_uniform_type_locals_operat, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 9576, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.check_uniform_type.operation.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_2generator14(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 9576, __pyx_L1_error)
__pyx_r = PySet_New(NULL); if (unlikely(!__pyx_r)) __PYX_ERR(0, 9576, __pyx_L1_error)
__Pyx_GOTREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 9576, __pyx_L1_error) }
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
for (;;) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9576, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 9576, __pyx_L1_error)
#else
__pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9576, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_v);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_v, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
if (unlikely(PySet_Add(__pyx_r, (PyObject*)((PyObject *)Py_TYPE(__pyx_cur_scope->__pyx_v_v))))) __PYX_ERR(0, 9576, __pyx_L1_error)
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_5generator15(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
/* … */
__Pyx_TraceLine(9576,0,__PYX_ERR(0, 9576, __pyx_L1_error))
__pyx_t_2 = __pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_9operation_genexpr(NULL, __pyx_v_val_list); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9576, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9576, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_val_types = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
/* … */
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_41_genexpr {
PyObject_HEAD
PyObject *__pyx_genexpr_arg_0;
PyObject *__pyx_v_v;
};
+9577: comp_types = set(type(c) for c in comp_list) if comp_list else set()
static PyObject *__pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_9operation_3genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_42_genexpr *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__pyx_cur_scope = (struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_42_genexpr *)__pyx_tp_new_6gofast_5tools_9coreutils___pyx_scope_struct_42_genexpr(__pyx_ptype_6gofast_5tools_9coreutils___pyx_scope_struct_42_genexpr, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_6gofast_5tools_9coreutils___pyx_scope_struct_42_genexpr *)Py_None);
__Pyx_INCREF(Py_None);
__PYX_ERR(0, 9577, __pyx_L1_error)
} else {
__Pyx_GOTREF((PyObject *)__pyx_cur_scope);
}
__pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
__Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
{
__pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_5generator15, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_genexpr, __pyx_n_s_check_uniform_type_locals_operat, __pyx_n_s_gofast_tools_coreutils); if (unlikely(!gen)) __PYX_ERR(0, 9577, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
}
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("gofast.tools.coreutils.check_uniform_type.operation.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__Pyx_DECREF((PyObject *)__pyx_cur_scope);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
static PyObject *__pyx_gb_6gofast_5tools_9coreutils_18check_uniform_type_9operation_5generator15(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("genexpr", 0);
__Pyx_TraceDeclarations
__pyx_L3_first_run:;
if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 9577, __pyx_L1_error)
__pyx_r = PySet_New(NULL); if (unlikely(!__pyx_r)) __PYX_ERR(0, 9577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_r);
if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 9577, __pyx_L1_error) }
__pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
__pyx_t_2 = 0;
for (;;) {
{
Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
#if !CYTHON_ASSUME_SAFE_MACROS
if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9577, __pyx_L1_error)
#endif
if (__pyx_t_2 >= __pyx_temp) break;
}
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
__pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely((0 < 0))) __PYX_ERR(0, 9577, __pyx_L1_error)
#else
__pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_c);
__Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_c, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
if (unlikely(PySet_Add(__pyx_r, (PyObject*)((PyObject *)Py_TYPE(__pyx_cur_scope->__pyx_v_c))))) __PYX_ERR(0, 9577, __pyx_L1_error)
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_r); __pyx_r = 0;
__Pyx_Generator_Replace_StopIteration(0);
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
__Pyx_XGIVEREF(__pyx_r);
#if !CYTHON_USE_EXC_INFO_STACK
__Pyx_Coroutine_ResetAndClearException(__pyx_generator);
#endif
__pyx_generator->resume_label = -1;
__Pyx_Coroutine_clear((PyObject*)__pyx_generator);
__Pyx_TraceReturn(__pyx_r, 0);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* … */
__Pyx_TraceLine(9577,0,__PYX_ERR(0, 9577, __pyx_L1_error))
__pyx_t_1 = (PyList_GET_SIZE(__pyx_v_comp_list) != 0);
if (__pyx_t_1) {
__pyx_t_2 = __pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_9operation_3genexpr(NULL, __pyx_v_comp_list); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_6 = __Pyx_Generator_Next(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_3 = __pyx_t_6;
__pyx_t_6 = 0;
} else {
__pyx_t_6 = PySet_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9577, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_3 = __pyx_t_6;
__pyx_t_6 = 0;
}
__pyx_v_comp_types = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
9578:
9579: # Compare types
+9580: if comparison_method == 'intersection':
__Pyx_TraceLine(9580,0,__PYX_ERR(0, 9580, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_comparison_method)) { __Pyx_RaiseClosureNameError("comparison_method"); __PYX_ERR(0, 9580, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_comparison_method, __pyx_n_u_intersection, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9580, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L10; }
+9581: common_types = val_types.intersection(comp_types) if comp_types else val_types
__Pyx_TraceLine(9581,0,__PYX_ERR(0, 9581, __pyx_L1_error)) __pyx_t_1 = (__pyx_v_comp_types != Py_None)&&(PySet_GET_SIZE(__pyx_v_comp_types) != 0); if (__pyx_t_1) { __pyx_t_6 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_intersection, __pyx_v_val_types, __pyx_v_comp_types); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9581, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } else { __Pyx_INCREF(__pyx_v_val_types); __pyx_t_3 = __pyx_v_val_types; } __pyx_v_common_types = __pyx_t_3; __pyx_t_3 = 0;
+9582: elif comparison_method == 'difference':
__Pyx_TraceLine(9582,0,__PYX_ERR(0, 9582, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_comparison_method)) { __Pyx_RaiseClosureNameError("comparison_method"); __PYX_ERR(0, 9582, __pyx_L1_error) } __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_comparison_method, __pyx_n_u_difference, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9582, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L10; }
+9583: common_types = val_types.difference(comp_types)
__Pyx_TraceLine(9583,0,__PYX_ERR(0, 9583, __pyx_L1_error)) __pyx_t_3 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PySet_Type_difference, __pyx_v_val_types, __pyx_v_comp_types); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9583, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_v_common_types = __pyx_t_3; __pyx_t_3 = 0;
9584: else:
+9585: if raise_exception:
__Pyx_TraceLine(9585,0,__PYX_ERR(0, 9585, __pyx_L1_error)) /*else*/ { if (unlikely(!__pyx_cur_scope->__pyx_v_raise_exception)) { __Pyx_RaiseClosureNameError("raise_exception"); __PYX_ERR(0, 9585, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_raise_exception); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9585, __pyx_L1_error) if (unlikely(__pyx_t_1)) { /* … */ }
+9586: raise ValueError(f"Invalid comparison method: {comparison_method}")
__Pyx_TraceLine(9586,0,__PYX_ERR(0, 9586, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_comparison_method)) { __Pyx_RaiseClosureNameError("comparison_method"); __PYX_ERR(0, 9586, __pyx_L1_error) } __pyx_t_3 = __Pyx_PyUnicode_Unicode(__pyx_cur_scope->__pyx_v_comparison_method); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Invalid_comparison_method, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9586, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 9586, __pyx_L1_error)
+9587: return False
__Pyx_TraceLine(9587,0,__PYX_ERR(0, 9587, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0; } __pyx_L10:;
9588:
9589: # Check for type uniformity
+9590: if not allow_mismatch and len(common_types) > 1:
__Pyx_TraceLine(9590,0,__PYX_ERR(0, 9590, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_allow_mismatch)) { __Pyx_RaiseClosureNameError("allow_mismatch"); __PYX_ERR(0, 9590, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_allow_mismatch); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9590, __pyx_L1_error) __pyx_t_5 = (!__pyx_t_4); if (__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L13_bool_binop_done; } __pyx_t_7 = PyObject_Length(__pyx_v_common_types); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9590, __pyx_L1_error) __pyx_t_5 = (__pyx_t_7 > 1); __pyx_t_1 = __pyx_t_5; __pyx_L13_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+9591: if raise_exception:
__Pyx_TraceLine(9591,0,__PYX_ERR(0, 9591, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_raise_exception)) { __Pyx_RaiseClosureNameError("raise_exception"); __PYX_ERR(0, 9591, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_raise_exception); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9591, __pyx_L1_error) if (unlikely(__pyx_t_1)) { /* … */ }
+9592: raise ValueError("Not all values are the same type.")
__Pyx_TraceLine(9592,0,__PYX_ERR(0, 9592, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__345, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9592, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 9592, __pyx_L1_error) /* … */ __pyx_tuple__345 = PyTuple_Pack(1, __pyx_kp_u_Not_all_values_are_the_same_type); if (unlikely(!__pyx_tuple__345)) __PYX_ERR(0, 9592, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__345); __Pyx_GIVEREF(__pyx_tuple__345);
+9593: return False
__Pyx_TraceLine(9593,0,__PYX_ERR(0, 9593, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
9594:
9595: # Conversion
+9596: if convert_values:
__Pyx_TraceLine(9596,0,__PYX_ERR(0, 9596, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_convert_values)) { __Pyx_RaiseClosureNameError("convert_values"); __PYX_ERR(0, 9596, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_convert_values); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9596, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+9597: if not target_type and not custom_conversion_func:
__Pyx_TraceLine(9597,0,__PYX_ERR(0, 9597, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_target_type)) { __Pyx_RaiseClosureNameError("target_type"); __PYX_ERR(0, 9597, __pyx_L1_error) } __pyx_t_5 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_cur_scope->__pyx_v_target_type)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 9597, __pyx_L1_error) __pyx_t_4 = (!__pyx_t_5); if (__pyx_t_4) { } else { __pyx_t_1 = __pyx_t_4; goto __pyx_L18_bool_binop_done; } if (unlikely(!__pyx_cur_scope->__pyx_v_custom_conversion_func)) { __Pyx_RaiseClosureNameError("custom_conversion_func"); __PYX_ERR(0, 9597, __pyx_L1_error) } __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_custom_conversion_func); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 9597, __pyx_L1_error) __pyx_t_5 = (!__pyx_t_4); __pyx_t_1 = __pyx_t_5; __pyx_L18_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+9598: if raise_exception:
__Pyx_TraceLine(9598,0,__PYX_ERR(0, 9598, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_raise_exception)) { __Pyx_RaiseClosureNameError("raise_exception"); __PYX_ERR(0, 9598, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_raise_exception); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9598, __pyx_L1_error) if (unlikely(__pyx_t_1)) { /* … */ }
+9599: raise ValueError("Target type or custom conversion "
__Pyx_TraceLine(9599,0,__PYX_ERR(0, 9599, __pyx_L1_error)) __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__346, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9599, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 9599, __pyx_L1_error) /* … */ __pyx_tuple__346 = PyTuple_Pack(1, __pyx_kp_u_Target_type_or_custom_conversion); if (unlikely(!__pyx_tuple__346)) __PYX_ERR(0, 9599, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__346); __Pyx_GIVEREF(__pyx_tuple__346);
9600: "function must be specified for conversion.")
+9601: return False
__Pyx_TraceLine(9601,0,__PYX_ERR(0, 9601, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; goto __pyx_L0;
+9602: try:
__Pyx_TraceLine(9602,0,__PYX_ERR(0, 9602, __pyx_L1_error)) { /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; goto __pyx_L26_try_end; __pyx_L21_error:; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L23_except_error:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L1_error; __pyx_L24_except_return:; __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); goto __pyx_L0; __pyx_L26_try_end:; }
+9603: if custom_conversion_func:
__Pyx_TraceLine(9603,0,__PYX_ERR(0, 9603, __pyx_L21_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_custom_conversion_func)) { __Pyx_RaiseClosureNameError("custom_conversion_func"); __PYX_ERR(0, 9603, __pyx_L21_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_custom_conversion_func); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9603, __pyx_L21_error) if (__pyx_t_1) { /* … */ goto __pyx_L27; }
+9604: converted_values = [custom_conversion_func(v) for v in val_list]
__Pyx_TraceLine(9604,0,__PYX_ERR(0, 9604, __pyx_L21_error)) { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9604, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __pyx_v_val_list; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9604, __pyx_L30_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 9604, __pyx_L30_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9604, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_XDECREF_SET(__pyx_9genexpr86__pyx_v_v, __pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_cur_scope->__pyx_v_custom_conversion_func)) { __Pyx_RaiseClosureNameError("custom_conversion_func"); __PYX_ERR(0, 9604, __pyx_L30_error) } __Pyx_INCREF(__pyx_cur_scope->__pyx_v_custom_conversion_func); __pyx_t_11 = __pyx_cur_scope->__pyx_v_custom_conversion_func; __pyx_t_12 = NULL; __pyx_t_13 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_11))) { __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); if (likely(__pyx_t_12)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_13 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_9genexpr86__pyx_v_v}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_11, __pyx_callargs+1-__pyx_t_13, 1+__pyx_t_13); __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9604, __pyx_L30_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 9604, __pyx_L30_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_9genexpr86__pyx_v_v); __pyx_9genexpr86__pyx_v_v = 0; goto __pyx_L34_exit_scope; __pyx_L30_error:; __Pyx_XDECREF(__pyx_9genexpr86__pyx_v_v); __pyx_9genexpr86__pyx_v_v = 0; goto __pyx_L21_error; __pyx_L34_exit_scope:; } /* exit inner scope */ __pyx_v_converted_values = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0;
9605: else:
+9606: converted_values = [target_type(v) for v in val_list]
__Pyx_TraceLine(9606,0,__PYX_ERR(0, 9606, __pyx_L21_error)) /*else*/ { { /* enter inner scope */ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9606, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __pyx_v_val_list; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9606, __pyx_L37_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_2 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 9606, __pyx_L37_error) #else __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9606, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_2); #endif __Pyx_XDECREF_SET(__pyx_9genexpr87__pyx_v_v, __pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_cur_scope->__pyx_v_target_type)) { __Pyx_RaiseClosureNameError("target_type"); __PYX_ERR(0, 9606, __pyx_L37_error) } __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_cur_scope->__pyx_v_target_type), __pyx_9genexpr87__pyx_v_v); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9606, __pyx_L37_error) __Pyx_GOTREF(__pyx_t_2); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 9606, __pyx_L37_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_9genexpr87__pyx_v_v); __pyx_9genexpr87__pyx_v_v = 0; goto __pyx_L41_exit_scope; __pyx_L37_error:; __Pyx_XDECREF(__pyx_9genexpr87__pyx_v_v); __pyx_9genexpr87__pyx_v_v = 0; goto __pyx_L21_error; __pyx_L41_exit_scope:; } /* exit inner scope */ __pyx_v_converted_values = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; } __pyx_L27:;
+9607: except Exception as e:
__Pyx_TraceLine(9607,0,__PYX_ERR(0, 9607, __pyx_L23_except_error)) __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0]))); if (__pyx_t_13) { __Pyx_AddTraceback("gofast.tools.coreutils.check_uniform_type.operation", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_2) < 0) __PYX_ERR(0, 9607, __pyx_L23_except_error) __Pyx_XGOTREF(__pyx_t_3); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __pyx_v_e = __pyx_t_6; /*try:*/ { /* … */ __Pyx_TraceLine(9607,0,__PYX_ERR(0, 9607, __pyx_L47_error)) /*finally:*/ { __pyx_L47_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_13 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15; goto __pyx_L23_except_error; } __pyx_L46_return: { __pyx_t_21 = __pyx_r; __pyx_r = 0; __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0; __pyx_r = __pyx_t_21; __pyx_t_21 = 0; goto __pyx_L24_except_return; } } } goto __pyx_L23_except_error;
+9608: if raise_exception:
__Pyx_TraceLine(9608,0,__PYX_ERR(0, 9608, __pyx_L47_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_raise_exception)) { __Pyx_RaiseClosureNameError("raise_exception"); __PYX_ERR(0, 9608, __pyx_L47_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_raise_exception); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9608, __pyx_L47_error) if (unlikely(__pyx_t_1)) { /* … */ }
+9609: raise ValueError(f"Conversion failed: {e}")
__Pyx_TraceLine(9609,0,__PYX_ERR(0, 9609, __pyx_L47_error)) __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9609, __pyx_L47_error) __Pyx_GOTREF(__pyx_t_11); __pyx_t_12 = __Pyx_PyUnicode_Concat(__pyx_kp_u_Conversion_failed, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 9609, __pyx_L47_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 9609, __pyx_L47_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_Raise(__pyx_t_11, 0, 0, 0); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __PYX_ERR(0, 9609, __pyx_L47_error)
+9610: return False
__Pyx_TraceLine(9610,0,__PYX_ERR(0, 9610, __pyx_L47_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_False); __pyx_r = Py_False; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L46_return; }
+9611: if return_types:
__Pyx_TraceLine(9611,0,__PYX_ERR(0, 9611, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_return_types)) { __Pyx_RaiseClosureNameError("return_types"); __PYX_ERR(0, 9611, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_return_types); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9611, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+9612: return converted_values, [type(v) for v in converted_values]
__Pyx_TraceLine(9612,0,__PYX_ERR(0, 9612, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9612, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __pyx_v_converted_values; __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9612, __pyx_L57_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 9612, __pyx_L57_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9612, __pyx_L57_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_9genexpr88__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)((PyObject *)Py_TYPE(__pyx_9genexpr88__pyx_v_v))))) __PYX_ERR(0, 9612, __pyx_L57_error) } __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_9genexpr88__pyx_v_v); __pyx_9genexpr88__pyx_v_v = 0; goto __pyx_L61_exit_scope; __pyx_L57_error:; __Pyx_XDECREF(__pyx_9genexpr88__pyx_v_v); __pyx_9genexpr88__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L61_exit_scope:; } /* exit inner scope */ __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9612, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_converted_values); __Pyx_GIVEREF(__pyx_v_converted_values); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_converted_values)) __PYX_ERR(0, 9612, __pyx_L1_error); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2)) __PYX_ERR(0, 9612, __pyx_L1_error); __pyx_t_2 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+9613: return converted_values
__Pyx_TraceLine(9613,0,__PYX_ERR(0, 9613, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(__pyx_v_converted_values); __pyx_r = __pyx_v_converted_values; goto __pyx_L0;
9614:
9615: # Return types
+9616: if return_types:
__Pyx_TraceLine(9616,0,__PYX_ERR(0, 9616, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_return_types)) { __Pyx_RaiseClosureNameError("return_types"); __PYX_ERR(0, 9616, __pyx_L1_error) } __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_return_types); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 9616, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+9617: if infer_types or len(common_types) > 1:
__Pyx_TraceLine(9617,0,__PYX_ERR(0, 9617, __pyx_L1_error)) if (unlikely(!__pyx_cur_scope->__pyx_v_infer_types)) { __Pyx_RaiseClosureNameError("infer_types"); __PYX_ERR(0, 9617, __pyx_L1_error) } __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_infer_types); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 9617, __pyx_L1_error) if (!__pyx_t_5) { } else { __pyx_t_1 = __pyx_t_5; goto __pyx_L64_bool_binop_done; } __pyx_t_7 = PyObject_Length(__pyx_v_common_types); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 9617, __pyx_L1_error) __pyx_t_5 = (__pyx_t_7 > 1); __pyx_t_1 = __pyx_t_5; __pyx_L64_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+9618: return [type(v) for v in val_list]
__Pyx_TraceLine(9618,0,__PYX_ERR(0, 9618, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); { /* enter inner scope */ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9618, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = __pyx_v_val_list; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; for (;;) { { Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2); #if !CYTHON_ASSUME_SAFE_MACROS if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 9618, __pyx_L68_error) #endif if (__pyx_t_7 >= __pyx_temp) break; } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_3); __pyx_t_7++; if (unlikely((0 < 0))) __PYX_ERR(0, 9618, __pyx_L68_error) #else __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9618, __pyx_L68_error) __Pyx_GOTREF(__pyx_t_3); #endif __Pyx_XDECREF_SET(__pyx_9genexpr89__pyx_v_v, __pyx_t_3); __pyx_t_3 = 0; if (unlikely(__Pyx_ListComp_Append(__pyx_t_6, (PyObject*)((PyObject *)Py_TYPE(__pyx_9genexpr89__pyx_v_v))))) __PYX_ERR(0, 9618, __pyx_L68_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_9genexpr89__pyx_v_v); __pyx_9genexpr89__pyx_v_v = 0; goto __pyx_L72_exit_scope; __pyx_L68_error:; __Pyx_XDECREF(__pyx_9genexpr89__pyx_v_v); __pyx_9genexpr89__pyx_v_v = 0; goto __pyx_L1_error; __pyx_L72_exit_scope:; } /* exit inner scope */ __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
+9619: return list(common_types)
__Pyx_TraceLine(9619,0,__PYX_ERR(0, 9619, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_6 = PySequence_List(__pyx_v_common_types); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 9619, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_r = __pyx_t_6; __pyx_t_6 = 0; goto __pyx_L0;
9620:
+9621: return True
__Pyx_TraceLine(9621,0,__PYX_ERR(0, 9621, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __Pyx_INCREF(Py_True); __pyx_r = Py_True; goto __pyx_L0;
9622:
+9623: return operation if return_func else operation()
__Pyx_TraceLine(9623,0,__PYX_ERR(0, 9623, __pyx_L1_error)) __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_return_func); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 9623, __pyx_L1_error) if (__pyx_t_2) { __Pyx_INCREF(__pyx_v_operation); __pyx_t_1 = __pyx_v_operation; } else { __pyx_t_3 = __pyx_pf_6gofast_5tools_9coreutils_18check_uniform_type_operation(__pyx_v_operation); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 9623, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_1 = __pyx_t_3; __pyx_t_3 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
9624:
9625: